/*
10-24-2008 - Tim Fischer
edlv.js  1.5.08 - Debug
edListView Javascript functions	
*/

var tfCtrlSelect=false;
var tfShiftSelect=false;
var tfActiveGrid=null;
var tfUsingArrows=false;
var _autoWidths=[];
function edMenu(gID,mouseMargin,openEvent){
var isOpen=false;
var trg=_gE(gID+'Chk');
var mnu=document.createElement("div");
mnu.className='edMenu';
var strHTML="<a href='javascript:void(0)' onclick='"+gID+".Rows.SelectAllRows();'>Select All</a><br /><a href='javascript:void(0);' onclick='"+gID+".Rows.SelectAllRows(true);'>Select Page</a><br /><a href='javascript:void(0);' onclick='"+gID+".Rows.ClearSelectedRows(true);'>Clear Selected</a>";
mnu.innerHTML=strHTML;
_gE(gID+'Container').appendChild(mnu);
function onMouseMove(ev){
var e=new xEvent(ev);
if(!xHasPoint(mnu,e.pageX,e.pageY,-mouseMargin)&&
!xHasPoint(trg,e.pageX,e.pageY,-mouseMargin)){
mnu.style.visibility='hidden';
edRemoveEvent(document,'mousemove',onMouseMove);
isOpen=false;
}
}
function onOpen(){
if(!isOpen){
xMoveTo(mnu,xPageX(trg),xHeight(trg));
mnu.style.visibility='visible';
edAddEvent(document,'mousemove',onMouseMove);
isOpen=true;
}
}
if(trg&&mnu){
edAddEvent(trg,openEvent,onOpen);
}
}
function tf_AdjWidth(_lvObj){
this.lvObj=_lvObj;
this.oResizeTarget=this.iStartX=this.iEndX=this.iSizeX=this.oVBar=null;
function getOwnerHeader(oObj){
var oElement=oObj;
while(oElement!=null&&oElement.tagName!=null&&oElement.tagName!='BODY'){
if(oElement.tagName.toUpperCase()=='TH'){return oElement;}
oElement=oElement.parentElement;
}
return null;
}
function getFirstColumnCell(objTable,iCellIndex){var oHeaderCell=objTable.rows(0).cells(iCellIndex);return oHeaderCell;}
function cleanUp(){
if(_lvObj.oVBar){_lvObj.oVBar.runtimeStyle.display="none";}
this.iEndX=this.iSizeX=this.iStartX=this.oResizeTarget=this.oAdjacentCell=null;
return true;
}
function onMouseMove(){
if(tfActiveGrid==null){return;}
var objTH=getOwnerHeader(event.srcElement);
if(!objTH){return;}
if(!_lvObj.oVBar){return;}
var oAdjacentCell=objTH.nextSibling;
if((event.offsetX>=(objTH.offsetWidth-10))&&(event.offsetX<=(objTH.offsetWidth+10)))
{tfActiveGrid.Table().style.cursor="e-resize";}else{tfActiveGrid.Table().style.cursor="pointer";}
if(_lvObj.oVBar.runtimeStyle.display=="inline")
{_lvObj.oVBar.runtimeStyle.left=window.event.clientX+document.body.scrollLeft-12;document.selection.empty();}
return true;
}
function onMouseDown(){
if(tfActiveGrid.Table()==null){return;}
var oTargetCell=event.srcElement;
if(!oTargetCell){return;}
if(!_lvObj.oVBar){return;}
if(oTargetCell.parentElement.tagName.toUpperCase()=="TH")
{oTargetCell=oTargetCell.parentElement;}
var el=_gE(_lvObj.HTMLID);
var oHeaderCell=getFirstColumnCell(el,oTargetCell.cellIndex);
this.iStartX=event.screenX;this.oResizeTarget=oHeaderCell;
if(tfActiveGrid.Table().style.cursor=="e-resize"){
el.setAttribute("Resizing","true");el.setCapture();
_lvObj.oVBar.runtimeStyle.left=window.event.clientX+document.body.scrollLeft-12;
_lvObj.oVBar.runtimeStyle.top=el.parentElement.offsetTop+el.offsetTop+2;
_lvObj.oVBar.runtimeStyle.height=el.parentElement.clientHeight-2;
_lvObj.oVBar.runtimeStyle.display="inline";
}
edFixEvent.preventDefault();
return false;
}
function onMouseUp(){
if(tfActiveGrid.Table()==null){return;}
var iResizeOldWidth=0;
var el=_gE(_lvObj.HTMLID);
if(this.iStartX!=null&&this.oResizeTarget!=null){
this.iEndX=event.screenX-6;this.iSizeX=this.iEndX-this.iStartX;el.setAttribute("Resizing","false");
if((this.oResizeTarget.offsetWidth+this.iSizeX)>=18){
if(Math.abs(this.iSizeX)>=18){
iResizeOldWidth=this.oResizeTarget.offsetWidth;
this.oResizeTarget.parentNode.parentNode.parentNode.style.width=xWidth(this.oResizeTarget.parentNode.parentNode.parentNode)+this.iSizeX+"px";
this.oResizeTarget.style.width=iResizeOldWidth+this.iSizeX;
}
}
else{this.oResizeTarget.style.width=18;}
}
cleanUp();
el.releaseCapture();
edFixEvent.preventDefault();
return false;
}
function CreateVBar(){
this.oVBar=document.createElement("SPAN");
this.oVBar.id=this.Name+"VBar";
this.oVBar.style.position="absolute";
this.oVBar.style.top="0px";
this.oVBar.style.left="0px";
this.oVBar.style.height="0px";
this.oVBar.style.width="2px";
this.oVBar.style.background="silver";
this.oVBar.style.borderLeft="1px solid black";
this.oVBar.style.display="none";
this.lvObj.oVBar=this.oVBar;
this.lvObj.lvCon.appendChild(this.oVBar);
}
function Initialize(el){
this.CreateVBar();
edAddEvent(el,'mousemove',this.onMouseMove);
edAddEvent(el,'mouseup',this.onMouseUp);
edAddEvent(el,'mousedown',this.onMouseDown);
this.Initialized=true;
}
this.CreateVBar=CreateVBar;
this.Initialize=Initialize;
this.getOwnerHeader=getOwnerHeader;
this.onMouseMove=onMouseMove;
this.onMouseUp=onMouseUp;
this.onMouseDown=onMouseDown;
}
function edFreezeHeader(sTableId,VisibleCols){
var sRoot='edRoot';
var sCC='edCaption';
var sFR='edFzRow';
var sTC='edTblCon';
var sCellT='edTable edRow edHeader';
var i;
var cc=null;
var frh;
var root;
var fr;
var tblContent;
var newHdr;
var tmr=null;
var origTbl=_gE(sTableId+'edTable0');
var origHdr=_gE(sTableId+'HD').parentNode;
var tColWidth=0;
if(!origTbl||!document.createElement||!document.appendChild||!origTbl.deleteCaption||!origTbl.deleteTHead){
return null;
}
function cloneHeader(elOrig,elNew){
var x=elOrig.cloneNode(true);
elNew.appendChild(x);
}
function onScroll(){
xLeft(fr,-tblContent.scrollLeft);
}
function onResize(){
setTimeout(function(){resize();},5);
if(!tmr){tmr=setTimeout(function(){resize();tmr=null;},500);}
}
function resize(){
if(origTbl.rows.length>0){
var cch=0;
if(cc)
{
cch=xHeight(cc);
xMoveTo(cc,0,0);
xWidth(cc,xWidth(root));
}
xMoveTo(newHdr,0,0);
xMoveTo(fr,0,cch);
xResizeTo(fr,xWidth(origTbl),frh);
xMoveTo(tblContent,0,0+frh);
xWidth(tblContent,xWidth(root));
xHeight(tblContent,xHeight(root)-frh);
tColWidth=0;
var frSizes=fr.children[0].cells;
for(var i=0;i<frSizes.length;++i){
origTbl.rows[0].cells[i].style.width=frSizes[i].style.width=VisibleCols[i].ColWidth;
tColWidth=parseInt(VisibleCols[i].ColWidth.replace("px",""))+tColWidth;
}
if(tColWidth<tblContent.offsetWidth){
frSizes[frSizes.length-1].style.width='100%';
origTbl.rows[0].cells[frSizes.length-1].style.width='100%';
}
onScroll();
}
}
frh=xHeight(origTbl.rows[0]);
root=document.createElement('div');
root.className=sRoot;
fr=document.createElement('div');
fr.className=sFR;
root.appendChild(fr);
tblContent=document.createElement('div');
tblContent.className=sTC;
root.appendChild(tblContent);
if(origTbl.caption){
cc=document.createElement('div');
cc.className=sCC;
cc.appendChild(origTbl.caption.firstChild);
root.appendChild(cc);
origTbl.deleteCaption();
}
newHdr=document.createElement('table');
newHdr.className=sCellT;
newHdr.id=sTableId+"edTableH";
var hdrSize=xGetElementsByTagName('TH',sTableId+'HD');
cloneHeader(origHdr,newHdr);
fr.appendChild(newHdr);
if(origTbl.tHead){origTbl.deleteTHead();}
origTbl=origTbl.parentNode.replaceChild(root,origTbl);
tblContent.appendChild(origTbl);
resize();
root.style.visibility='visible';
edRemoveEvent(window,'resize',onResize);
edAddEvent(tblContent,'scroll',onScroll);
edAddEvent(window,'resize',onResize);
}
function tf_Fields(){
this.lvObj=null;this.Fields=[];this.VisibleFields=null;function Field(_lvObj,_ID,_Name){
this.lvObj=_lvObj;this.ID=_ID;this.Name=_Name;this.DefaultValue=null;this.DataSource=null;
function GetDisplayHTML(_Value){var html=_Value;return html;}function GetEditHTML(_Cell){var html="<input type='textbox' value='"+_Cell.Value+"' />";return html;}function GetEvalObjectString(){return this.ParentObject.GetEvalObjectString()+"_Fields"+this.ID;}
function SetValue(_Cell,_Value){return _Cell.SetValue(_Value);}
function Onload(_Cell){
try
{_gE(_Cell.HTMLID).children[0].focus();_gE(_Cell.HTMLID).children[0].select();}catch(exception){}
}this.GetDisplayHTML=GetDisplayHTML;this.GetEditHTML=GetEditHTML;this.GetEvalObjectString=GetEvalObjectString;this.SetValue=SetValue;this.Onload=Onload;
}function InsertField(_Name){this.Fields[this.Fields.length]=new Field(this.lvObj,this.Fields.length,_Name);return this.Fields[this.Fields.length-1];}function Initialize(){}this.Field=Field;this.Initialize=Initialize;this.InsertField=InsertField;
}
var tfFields=new tf_Fields();
function tfStringField_GetDisplayHTML(_Value){
var html=_Value;
return html;
}
function tfStringField_GetEditHTML(_Cell){
var html="<input class=\"spTxtboxs\" type='textbox' size="+(_gE(_Cell.HTMLID).offsetWidth/10)+" value='"+_Cell.Value+"' onchange=\""+_Cell.GetEvalObjectString()+".SetValue(this.value) \" />";
return html;
}
function tfNumberField_GetDisplayHTML(_Value){
var html=_Value;
return html;
}
function tfNumberField_GetEditHTML(_Cell){
var html="<input class=\"spTxtboxs\" type='textbox' size="+(_gE(_Cell.HTMLID).offsetWidth/10)+" onchange='if(isNaN(this.value) == false){ "+_Cell.GetEvalObjectString()+".SetValue(this.value) }' value='"+_Cell.Value+"' />";
return html;
}
function tfDateField_CheckData(_NewValue,_Cell){
var dateArray=_NewValue.split("/");
if(dateArray.length==3){
if(isNaN(dateArray[0])==false&&isNaN(dateArray[1])==false&&isNaN(dateArray[2])==false){
var day=Number(dateArray[0]);
var month=Number(dateArray[1]);
var year=Number(dateArray[2]);
var date=new Date(year,month,day);
_Cell.SetValue(date);
}
}
}
function tfDateField_GetDisplayHTML(_Value){
if(_Value==""||_Value==null){return"";}
var html=('0'+_Value.getDate()).substr((_Value.getDate().toString().length>1?1:0),2)+'/'+('0'+_Value.getMonth()).substr((_Value.getMonth().toString().length>1?1:0),2)+'/'+_Value.getFullYear();
return html;
}
function tfDateField_GetEditHTML(_Cell){
var dateString;
if(_Cell.Value!=null&&_Cell.Value!=""&&_Cell.Value!=undefined){
dateString=(_Cell.Value.getDate()>9?_Cell.Value.getDate():"0"+_Cell.Value.getDate())+
"/"+
((_Cell.Value.getMonth()+1)>9?_Cell.Value.getMonth():"0"+_Cell.Value.getMonth())+
"/"+
_Cell.Value.getFullYear();
}
else{
dateString="null";
}
var html="<input class=\"spTxtboxs\" type='textbox' size=12 title='Input format must be dd/mm/yyyy' onchange='tfDateField_CheckData(this.value,"+_Cell.GetEvalObjectString()+")' value='"+dateString+"' />";
return html;
}
function tfMemoField_GetDisplayHTML(_Value){
var html=_Value.toString().replace(/\n/gi,'<br />');
return html;
}
function tfMemoField_GetEditHTML(_Cell){
var eStr=_Cell.GetEvalObjectString();
var retStr="<Textarea onchange='"+eStr+".SetValue(this.value)'>"+_Cell.Value+" </Textarea>";
return retStr;
}
function tfBooleanField_GetDisplayHTML(_Value){
var chk=(_Value=="1"?"checked":"");
var html="<input id='cb1' type='checkbox' "+chk+" disabled='disabled' />";
return html;
}
function tfBooleanField_GetEditHTML(_Cell){
var html="<input type='checkbox' onchange='"+_Cell.GetEvalObjectString()+".SetValue(this.checked?1:0)' "+(_Cell.Value=="1"?"checked":"")+">";
return html;
}
function tfSelectboxField_GetDisplayHTML(_Value) {
    var text = ""; var nX;
    for (nX in this.DataSource) { if (this.DataSource[nX][0] == _Value) { text = this.DataSource[nX][1]; } } return text;
}
function tfSelectboxField_GetEditHTML(_Cell) {
    var text = "<select class='Selectbox' onchange='" + _Cell.GetEvalObjectString() + ".SetValue(this.options[this.selectedIndex].value)'>"; var nX;
    for (nX in this.DataSource) { text += "<option value = " + this.DataSource[nX][0] + " " + (this.DataSource[nX][0] == _Cell.Value ? "selected" : "") + ">" + this.DataSource[nX][1] + "</option>"; } text += "</select>"; return text;
}
// SELECTBOX MODE
function tfRadioGroupField_GetDisplayHTML(_Value) {
    var text = "";
    for (var nX in this.DataSource) { if (this.DataSource[nX][0] == _Value) { text = this.DataSource[nX][1]; } } return text;
}
function tfRadioGroupField_GetEditHTML(_Cell) { var text = ""; for (var nX in this.DataSource) { text += "<input type='radio' name='" + _Cell.Name + "' onclick='" + _Cell.GetEvalObjectString() + ".SetValue(this.value)' value = '" + this.DataSource[nX][0] + "' " + (this.DataSource[nX][0] == _Cell.Value ? "checked" : "") + "> " + this.DataSource[nX][1]; } return text; }

tfStringField=tfFields.InsertField("String");
tfStringField.DefaultValue=2;
tfStringField.GetEditHTML=tfStringField_GetEditHTML;
tfNumberField=tfFields.InsertField("Number");
tfNumberField.DefaultValue=0;
tfNumberField.GetDisplayHTML=tfNumberField_GetDisplayHTML;
tfNumberField.GetEditHTML=tfNumberField_GetEditHTML;
tfDateField=tfFields.InsertField("Date");
tfDateField.DefaultValue=0;
tfDateField.GetDisplayHTML=tfDateField_GetDisplayHTML;
tfDateField.GetEditHTML=tfDateField_GetEditHTML;
tfMemoField=tfFields.InsertField("Memo");
tfMemoField.DefaultValue=2;
tfMemoField.GetDisplayHTML=tfMemoField_GetDisplayHTML;
tfMemoField.GetEditHTML=tfMemoField_GetEditHTML;
tfBooleanField=tfFields.InsertField("Boolean");
tfBooleanField.DefaultValue=1;
tfBooleanField.GetDisplayHTML=tfBooleanField_GetDisplayHTML;
tfBooleanField.GetEditHTML=tfBooleanField_GetEditHTML;
tfSelectboxField=tfFields.InsertField("Selectbox");
tfSelectboxField.DefaultValue=2;
tfSelectboxField.GetDisplayHTML=tfSelectboxField_GetDisplayHTML;
tfSelectboxField.GetEditHTML=tfSelectboxField_GetEditHTML;
tfRadioGroupField=tfFields.InsertField("RadioGroup");
tfRadioGroupField.DefaultValue=2;
tfRadioGroupField.GetDisplayHTML=tfSelectboxField_GetDisplayHTML;
tfRadioGroupField.GetEditHTML=tfRadioGroupField_GetEditHTML;
function tf_Cells(_lvObj,_Row){
this.lvObj=_lvObj;
this.Row=_Row;
this.Cells=[];
function tf_Cell(_ID,_lvObj,_Row,_Value,_Field,_Column){
this.lvObj=_lvObj;
this.Row=_Row;
this.ID=_ID;
this.HTMLID=this.lvObj.Name+"R"+this.Row.ID+"C"+this.ID;
this.Value=_Value;
this.Field=_Field;
this.Column=_Column;
this.BackupValue=null;
this.Selected=false;
this.Edited=false;
function GetEvalObjectString(){return this.Row.GetEvalObjectString()+".GetRowView().Cells.Cells["+this.ID+"]";}
function RePaint(){_gE(this.HTMLID).innerHTML=this.Field.GetDisplayHTML(this.lvObj.Datas.CurrentDatas[this.Row.Data.KeyID].Data[this.Column.ID]);}
function CancelEdit(){this.SetValue(this.BackupValue);}function EditMode(){
if(this.Column.ReadOnly==true){this.Row.ChangeSelectionStatus(1);return;}if(this.Edited==false){
this.Row.ChangeSelectionStatus(3);
_gE(this.HTMLID).innerHTML=this.Field.GetEditHTML(this);this.Field.Onload(this);this.lvObj.Rows.EditedCell=this;this.lvObj.Rows.SelectedCell=null;this.Edited=true;this.BackupValue=this.Value;
}
}
function NormalMode(){
this.Edited=false;this.Selected=false;
this.BackupValue=null;if(_gE(this.HTMLID)){
this.Row.ChangeSelectionStatus(0);
_gE(this.HTMLID).innerHTML=this.Field.GetDisplayHTML(this.lvObj.Datas.CurrentDatas[this.Row.Data.KeyID].Data[this.Column.ID]);
}
}
function SelectMode(){
this.lvObj.Rows.ClearSelectedRows();this.Row.ChangeSelectionStatus(1);this.Selected=true;this.BackupValue=null;
this.lvObj.Rows.SelectedCell=this;
this.lvObj.Rows.EditedCell=null;
}
function SetValue(_Value){
if(this.Row.Data.Data[this.Column.ID]!=_Value){
this.lvObj.Datas.CurrentDatas[this.Row.Data.KeyID].Data[this.Column.ID]=_Value;
var modifiedData=this.lvObj.Datas.InsertModifiedData(this.Row.Data.KeyID);
modifiedData.Data[this.Column.ID]=_Value;
this.Row.Data.Data[this.Column.ID]=_Value;
}
}
function HTMLOutPut(){return this.Field.GetDisplayHTML(this.Value);}
this.GetEvalObjectString=GetEvalObjectString;
this.NormalMode=NormalMode;
this.EditMode=EditMode;
this.SelectMode=SelectMode;
this.CancelEdit=CancelEdit;
this.SetValue=SetValue;
this.RePaint=RePaint;
this.HTMLOutPut=HTMLOutPut;
}
    function InsertCell(_Field, _Column) { var cellID = this.Cells.length; this.Cells[cellID] = new this.Cell(cellID, this.lvObj, this.Row, this.Row.Data.Data[_Column.ID], _Field, _Column); }
    function GetCell(_FieldKey) {
        for (var nX in this.Cells) {
            if (this.Cells[nX].Column.Key == _FieldKey) {
                return this.Cells[nX];
            }
        }
    }
    function Initialize() {
        for (var nX in this.lvObj.Columns.Columns) {
            this.InsertCell(this.lvObj.Columns.Columns[nX].Field, this.lvObj.Columns.Columns[nX]);
        }
    }
    
this.Cell=tf_Cell;
this.Initialize=Initialize;
this.InsertCell=InsertCell;
this.GetCell=GetCell;
}
function tf_Columns(_lvObj){
this.lvObj=_lvObj;
this.Columns=[];
this.VisibleColumns=null;
function Column(_lvObj,_Columns,_ID,_Field,_Key,_Header,_Visible,_Class,_ColWidth){
this.lvObj=_lvObj;
this.Columns=_Columns;
this.ColWidth=_ColWidth;
this.ID=_ID;
this.Key=_Key;
this.Field=_Field;
this.Header=_Header;
this.Visible=_Visible;
this.DataType="";
this.ColumnName="";
this.allowHTML=false;
this.AllowDBNull=true;
this.AutoIncrement=false;
this.AutoIncrementStep=1;
this.DefaultValue=_Field.DefaultValue;
this.ReadOnly=true;
this.Unique=false;
this.LastAutoIncrementID=0;
this.Class=_Class;
function GetEvalObjectString(){
return this.ParentObject.GetEvalObjectString()+"_Columns"+this.ID;
}
function GetHTMLOutPutHeaders(_Table){
var sortImageHTML="";
var sortStyle="lvSort";
var len;
var sortJS;
if((_Table.Navigator.SortRotation==1)&&(_Table.Navigator.SortColumnIndex==this.ID)){sortStyle="lvSortA";}
else if((_Table.Navigator.SortRotation==0)&&(_Table.Navigator.SortColumnIndex==this.ID)){sortStyle="lvSortZ";}
if((this.Header.length==0||this.Header.indexOf(this.lvObj.Name+"Chk")>0)&&this.lvObj.AllowUserSelection&&this.lvObj.AllowMultiSelect){
this.Header="<img id='"+this.lvObj.Name+"Chk' border='0' class='edTrigger' src='"+this.lvObj.ResourcePath+"images/mRSelU.gif.ashx'></img>";
len=2;sortJS="javascript:void(0);";
}
else{
len=this.Header.length;sortJS=_Table.GetEvalObjectString()+".Navigator.Sort("+this.ID+");";
}
var slen='';
if(_ColWidth.length>1){slen=this.ColWidth+';';}else{slen=(len*8)+'px';}
var html="<th style='width:"+slen+"'"+
(this.lvObj.AllowGroupBy==true?" onmousedown=\""+this.lvObj.Name+".Events.dragStart(event, '"+this.lvObj.Name+"uimg', '<div class=HDrag>"+this.Header+"</div>', "+_Table.GetEvalObjectString()+".lvObj.Columns.Columns["+this.ID+"]); \"":"")+
(this.lvObj.AllowSorting==true?" onclick=\""+sortJS+"\"":"")+
">"+this.Header+"<div class='"+sortStyle+"'></div></th>";
return html;
}
function GetHTMLOutPutX(isFirstColumn){
var sortImageHTML="";
var sortStyle="lvSort";
var html="";
var colspan="1";
var len;
if(isFirstColumn&&this.lvObj.AllowUserSelection){
colspan=this.lvObj.GroupBy.Columns.length;
this.Header="<img id='"+this.lvObj.Name+"Chk' border='0' src='"+this.lvObj.ResourcePath+"images/mRSelU.gif.ashx'></a>";
len=2;
}else{
len=this.Header.length;
}
var dragHTML="<table><tr><td width='100%' class='EDHdrRow'>"+this.Header+"</td></tr></table>";
html+="<th style='width:"+len*8+"px;' colspan='"+colspan+"' style='cursor:hand;' onmousedown=\""+this.lvObj.Name+".Events.dragStart(event, '"+this.lvObj.Name+"uimg', '"+dragHTML+"', "+this.lvObj.GetEvalObjectString()+".Columns.Columns["+this.ID+"]); \" >"+
this.Header+"<div class='"+sortStyle+"'></div></th>";
return html;
}
this.GetHTMLOutPutHeaders=GetHTMLOutPutHeaders;
this.GetHTMLOutPutX=GetHTMLOutPutX;
}
function GetColumnsXML(){
var xml="";
for(var nX in this.Columns){
xml+="<Column>"+
"<Name>"+this.Columns[nX].ColumnName+"</Name>"+
"<DataType>"+this.Columns[nX].DataType+"</DataType>"+
"<AllowDBNull>"+this.Columns[nX].AllowDBNull+"</AllowDBNull>"+
"<AutoIncrement>"+this.Columns[nX].AutoIncrement+"</AutoIncrement>"+
"<AutoIncrementStep>"+this.Columns[nX].AutoIncrementStep+"</AutoIncrementStep>"+
"<DefaultValue>"+this.Columns[nX].DefaultValue+"</DefaultValue>"+
"<ReadOnly>"+this.Columns[nX].ReadOnly+"</ReadOnly>"+
"<Unique>"+this.Columns[nX].Unique+"</Unique>"+
"</Column>";
}
return xml;
}
function InsertColumn(_Field,_Key,_Header,_Visible,_Class,_ColWidth){
this.Columns[this.Columns.length]=new Column(this.lvObj,this,this.Columns.length,_Field,_Key,_Header,_Visible,_Class,_ColWidth);
return this.Columns[this.Columns.length-1];
}
this.GetColumnIndex=function(_ColumnName){
for(var nX in this.Columns){
if(this.Columns[nX].ColumnName==_ColumnName){
return nX;
}
}
return-1;
}
function GetColumnsDisplayInTable(){
var columnsDisplayInTable=[];
for(var nX in this.Columns){
if(this.Columns[nX].Visible==true&&this.lvObj.GroupBy.IsGroupByColumn(nX)==false){
columnsDisplayInTable[columnsDisplayInTable.length]=this.Columns[nX];
}
}
this.VisibleColumns=columnsDisplayInTable;
return columnsDisplayInTable;
}
function GetVisibleColumns(){
var columnsDisplayInTable=[];
for(var nX in this.Columns){
if(this.Columns[nX].Visible==true){
columnsDisplayInTable[columnsDisplayInTable.length]=this.Columns[nX];
}
}
this.VisibleColumns=columnsDisplayInTable;
return columnsDisplayInTable;
}
function Initialize(){
}
function GetHeaderPane(_Table){
var html=[];
html.push("<thead><tr id='"+this.lvObj.Name+"HD'>");
var columns=this.GetColumnsDisplayInTable();
for(var nX in columns){
html.push(columns[nX].GetHTMLOutPutHeaders(_Table));
if(columns[nX].ColumnName=="_tfAT"){this.setAutoWidth(2,nX);}
else{
this.setAutoWidth(columns[nX].Header.length,nX);
}
}
html.push("</tr></thead>");
return html.join('');
}
function GetHTMLOutPuts(){
var html=[];
html.push("<thead><tr id='"+this.lvObj.Name+"HD'>");
var columns=this.GetVisibleColumns();
var isFirstColumn=true;
for(var nX in columns){html.push(columns[nX].GetHTMLOutPutX(isFirstColumn));isFirstColumn=false;}
html.push("</tr></thead>");
return html.join('');
}
function setAutoWidth(curLen,colNo){
if(this.VisibleColumns[colNo].ColWidth==""){
this.VisibleColumns[colNo].ColWidth=(curLen*7)+10+'px';
return;
}
if(this.VisibleColumns[colNo].ColWidth.indexOf('\%')!=-1){return;}
var prevLen=this.VisibleColumns[colNo].ColWidth.replace("px","");
if(curLen==undefined){
this.VisibleColumns[colNo].ColWidth=(this.VisibleColumns[colNo].Header.length*7)+10+'px';
return;
}
if((curLen*7)+10>prevLen){
this.VisibleColumns[colNo].ColWidth=(curLen*7)+10+'px';
}
}
this.setAutoWidth=setAutoWidth;
this.Column=Column;
this.InsertColumn=InsertColumn;
this.GetHeaderPane=GetHeaderPane;
this.GetHTMLOutPuts=GetHTMLOutPuts;
this.GetColumnsDisplayInTable=GetColumnsDisplayInTable;
this.GetVisibleColumns=GetVisibleColumns;
this.Initialize=Initialize;
this.GetColumnsXML=GetColumnsXML;
}
function tf_Datas(_lvObj){
this.LastTakenID=0;
this.lvObj=_lvObj;
this.OrginalDatas=[];
this.CurrentDatas=[];
this.AddedDatas=[];
this.SelectedDatas=[];
this.ModifiedDatas=[];
this.DeletedDatas=[];
function GetDataByKeyID(_DataState,_KeyID){
if(_DataState=="Current"){
for(var key in this.CurrentDatas){
if(this.CurrentDatas[key]==null){
continue;
}
if(this.CurrentDatas[key].KeyID==_KeyID){
return this.CurrentDatas[key];
}
}
}
return null;
}
function GetNewID(){
return this.LastTakenID++;
}
function tf_Data(_lvObj,_ID,_DataKeyID,_Data){
var nX;
this.lvObj=_lvObj;
this.ID=_ID;
this.KeyID=_DataKeyID;
var datas=[];
for(nX=0;nX<_Data.length;nX++){
datas[nX]=_Data[nX];
}
this.Data=datas;
}
function GetEvalObjectString(){
return this.ParentObject.GetEvalObjectString()+".Rows";
}
function InsertData(_Data){
var keyID=this.GetNewID();
this.AddedDatas[keyID]=new this.Data(this.lvObj,this.AddedDatas.length,keyID,this.lvObj.GeneralFunctions.CloneArray(_Data));
this.CurrentDatas[keyID]=new this.Data(this.lvObj,this.CurrentDatas.length,keyID,this.lvObj.GeneralFunctions.CloneArray(_Data));
return(keyID);
}
function AcceptChanges(){
this.OrginalDatas=[];
for(var nX in this.CurrentDatas){
var data=new this.Data(this.CurrentDatas[nX].lvObj,nX,this.CurrentDatas[nX].KeyID,this.lvObj.GeneralFunctions.CloneArray(this.CurrentDatas[nX].Data));
this.OrginalDatas[nX]=data;
}
this.AddedDatas=[];
this.ModifiedDatas=[];
this.DeletedDatas=[];
this.SelectedDatas=[];
}
function IsInsertedData(_DataKeyID){
if(this.AddedDatas[_DataKeyID]!=null){
return true;
}
return false;
}
function IsModifiedData(_DataKeyID){
if(this.ModifiedDatas[_DataKeyID]!=null){
return true;
}
return false;
}
function IsSelectedData(_DataKeyID){
if(this.SelectedDatas[_DataKeyID]!=null){
return true;
}
return false;
}
function RemoveSelectionData(_DataKeyID){
if(this.SelectedDatas[_DataKeyID]!=null){
this.SelectedDatas[_DataKeyID]=null;
}
}
function InsertSelectedData(_DataKeyID){
if(this.SelectedDatas[_DataKeyID]!=null){
return this.SelectedDatas[_DataKeyID];
}
this.SelectedDatas[_DataKeyID]=new this.Data(this.lvObj,this.SelectedDatas.length,_DataKeyID,this.lvObj.GeneralFunctions.CloneArray(this.CurrentDatas[_DataKeyID].Data));
return this.SelectedDatas[_DataKeyID];
}
function InsertModifiedData(_DataKeyID){
if(this.ModifiedDatas[_DataKeyID]!=null){
return this.ModifiedDatas[_DataKeyID];
}
this.ModifiedDatas[_DataKeyID]=new this.Data(this.lvObj,this.ModifiedDatas.length,_DataKeyID,this.lvObj.GeneralFunctions.CloneArray(this.CurrentDatas[_DataKeyID].Data));
return this.ModifiedDatas[_DataKeyID];
}
function InsertDeletedData(_DataKeyID){
if(this.DeletedDatas[_DataKeyID]!=null){
return this.DeletedDatas[_DataKeyID];
}
if(this.ModifiedDatas[_DataKeyID]!=null){
this.ModifiedDatas[_DataKeyID]=null;
}
if(this.AddedDatas[_DataKeyID]!=null){
if(_DataKeyID==0){this.AddedDatas=[];this.CurrentDatas=[];}
else{this.AddedDatas[_DataKeyID]=null;this.DeleteCurrentData(_DataKeyID);}
return;
}
this.DeleteCurrentData(_DataKeyID);
this.DeletedDatas[_DataKeyID]=new this.Data(this.lvObj,this.DeletedDatas.length,_DataKeyID,this.lvObj.GeneralFunctions.CloneArray(this.OrginalDatas[_DataKeyID].Data));
return this.DeletedDatas[_DataKeyID];
}
function DeleteCurrentData(_DataKeyID){
if(this.CurrentDatas[_DataKeyID]!=null){
if(_DataKeyID==0){this.CurrentDatas=[];}
else{this.CurrentDatas[_DataKeyID]=null;}
}
}
function GetRowXML(_Datas,_DataIndex,_Selected){
var xml="";
for(var nY in this.lvObj.Columns.Columns){
if(_Datas[_DataIndex]!=null){
if(_Datas[_DataIndex].Data[nY]!=""&&_Datas[_DataIndex].Data[nY]!=null){
if(this.lvObj.Columns.Columns[nY].Field==tfDateField){
var date=_Datas[_DataIndex].Data[nY];
var dataString=date.getFullYear()+"-"+(date.getMonth()>9?date.getMonth():"0"+date.getMonth())+
"-"+(date.getDate()>9?date.getDate():"0"+date.getDate())+"T00:00:00%2B00:00";
xml+="<"+(this.lvObj.Columns.Columns[nY].Key).replace(/\s+/g,'')+">"+dataString+"</"+(this.lvObj.Columns.Columns[nY].Key).replace(/\s+/g,'')+">";
}
else
if(this.HasExcludedCharacters(_Datas[_DataIndex].Data[nY])==true){
xml+="<"+(this.lvObj.Columns.Columns[nY].Key).replace(/\s+/g,'')+">"+"<![CDATA_BEGIN["+_Datas[_DataIndex].Data[nY]+"]]END>"+"</"+(this.lvObj.Columns.Columns[nY].Key).replace(/\s+/g,'')+">";
}
else{
xml+="<"+(this.lvObj.Columns.Columns[nY].Key).replace(/\s+/g,'')+">"+_Datas[_DataIndex].Data[nY]+"</"+(this.lvObj.Columns.Columns[nY].Key).replace(/\s+/g,'')+">";
}
}
}
}
return xml;
}
function DiffGramXML(eventTarget){
var DeletedXml="";
var ModifiedOriginalDataXml="";
var ModifiedXml="";
var AddedXml="";
var SelXml="";
var AllXml="";
var ColumnsXml="<Columns>"+this.lvObj.Columns.GetColumnsXML()+"</Columns>";
var nX;
if(!this.lvObj.SendAllRowsInCallback){
if(this.lvObj.AllowEdit||this.lvObj.AllowAdd){
for(nX in this.ModifiedDatas){
if(this.ModifiedDatas[nX]==null){
continue;
}
var isInsertedData=this.IsInsertedData(this.ModifiedDatas[nX].KeyID);
if(isInsertedData==false){
ModifiedOriginalDataXml+="<ModifiedOriginalData>"+this.GetRowXML(this.OrginalDatas,nX)+"</ModifiedOriginalData>";
ModifiedXml+="<Modified>"+this.GetRowXML(this.ModifiedDatas,nX)+"</Modified>";
}
else{
if(this.AddedDatas[nX]==null){
continue;
}
AddedXml+="<Added>"+this.GetRowXML(this.ModifiedDatas,nX)+"</Added>";
}
}
if(this.lvObj.AllowDelete){
for(nX in this.DeletedDatas){
ModifiedOriginalDataXml+="<ModifiedOriginalData>"+this.GetRowXML(this.OrginalDatas,nX)+"</ModifiedOriginalData>";
DeletedXml+="<Deleted>"+this.GetRowXML(this.DeletedDatas,nX)+"</Deleted>";
}
}
}
for(nX in this.SelectedDatas){
if(this.SelectedDatas[nX]==null){
continue;
}
SelXml+="<Sel>"+
this.GetRowXML(this.SelectedDatas,nX,true)+
"</Sel>";
}
}
else{
for(nX in this.CurrentDatas){
if(this.CurrentDatas[nX]==null){
continue;
}
AllXml+="<All>"+
this.GetRowXML(this.CurrentDatas,nX,true)+
"</All>";
}
}
var xml="<?xml version=\"1.0\" standalone=\"yes\"?>"+
"<DataSet TableName='"+this.lvObj.TableName+"'>"+
ColumnsXml+
AddedXml+
ModifiedOriginalDataXml+
ModifiedXml+
DeletedXml+
SelXml+
AllXml+
"<eventTarget>"+eventTarget+"</eventTarget>"+
"</DataSet>";
return xml;
}
function HasExcludedCharacters(compareString){
if(isNaN(compareString)==false){
return false;
}
var excludedCharacters=["\""," < "," > ","\n"];
for(var nX=0;nX<4;nX++)
{
if(compareString.indexOf(excludedCharacters[nX])!=-1){
return true;
}
}
return false;
}
this.GetEvalObjectString=GetEvalObjectString;
this.Data=tf_Data;
this.Insert=InsertData;
this.AcceptChanges=AcceptChanges;
this.DeleteCurrentData=DeleteCurrentData;
this.InsertModifiedData=InsertModifiedData;
this.InsertSelectedData=InsertSelectedData;
this.RemoveSelectionData=RemoveSelectionData;
this.InsertDeletedData=InsertDeletedData;
this.DiffGramXML=DiffGramXML;
this.IsInsertedData=IsInsertedData;
this.IsModifiedData=IsModifiedData;
this.IsSelectedData=IsSelectedData;
this.GetRowXML=GetRowXML;
this.GetNewID=GetNewID;
this.GetDataByKeyID=GetDataByKeyID;
this.HasExcludedCharacters=HasExcludedCharacters;
}
function tf_Events(_lvObj){
this.lvObj=_lvObj;
this.Initialized=false;
this.InKeySelect=false;
this.InMouseSelect=false;
this.DragObject=null;
this.dragObj={};
this.dragObj.zIndex=10;
function dragStart(event,id,innerHTML,dragObject){
tfActiveGrid=this.lvObj;
var x,y;
this.DragObject=dragObject;
if(id){
this.dragObj.elNode=_gE(id);
}
else{
if(this.lvObj.Browser.isIE){
this.dragObj.elNode=window.event.srcElement;
}
if(this.lvObj.Browser.isNS){
this.dragObj.elNode=event.target;
}
if(this.dragObj.elNode.nodeType==3){
this.dragObj.elNode=this.dragObj.elNode.parentNode;
}
}
this.dragObj.elNode.innerHTML=innerHTML;
if(this.lvObj.Browser.isIE){
x=window.event.clientX+document.documentElement.scrollLeft+document.body.scrollLeft;
y=window.event.clientY+document.documentElement.scrollTop+document.body.scrollTop;
}
if(this.lvObj.Browser.isNS){
x=event.clientX+window.scrollX;
y=event.clientY+window.scrollY;
}
this.dragObj.cursorStartX=x;
this.dragObj.cursorStartY=y;
this.dragObj.elNode.style.left=window.event.clientX;
this.dragObj.elNode.style.top=window.event.clientY;
this.dragObj.elNode.style.zIndex=++this.dragObj.zIndex;
if(this.lvObj.Browser.isIE){
window.event.cancelBubble=true;
window.event.returnValue=false;
}
if(this.lvObj.Browser.isNS){
event.preventDefault();
}
document.body.style.cursor='move';
}
function dragGo(event){
var x,y;
if(tfActiveGrid.Events.dragObj.elNode.style.visibility!="visible"){
tfActiveGrid.Events.dragObj.elNode.style.visibility="visible";
}
if(tfActiveGrid.Browser.isIE){
x=window.event.clientX+document.documentElement.scrollLeft+document.body.scrollLeft;
y=window.event.clientY+document.documentElement.scrollTop+document.body.scrollTop;
}
if(tfActiveGrid.Browser.isNS){
x=event.clientX+window.scrollX;
y=event.clientY+window.scrollY;
}
tfActiveGrid.Events.dragObj.elNode.style.left=window.event.clientX;
tfActiveGrid.Events.dragObj.elNode.style.top=window.event.clientY;
if(tfActiveGrid.Browser.isIE){
window.event.cancelBubble=true;
window.event.returnValue=false;
}
if(tfActiveGrid.Browser.isNS){
event.preventDefault();
}
}
function dragStop(event){
if(tfActiveGrid.Browser.isIE){
if(tfActiveGrid.Events.dragObj.elNode!=null){
tfActiveGrid.Events.dragObj.elNode.style.visibility="hidden";
}
}
if(tfActiveGrid.Browser.isNS){
edRemoveEvent("mousemove",tfActiveGrid.Events.dragGo,true);
edRemoveEvent("mouseup",tfActiveGrid.Events.dragStop,true);
}
document.body.style.cursor='auto';
tfActiveGrid.Events.dragObj.elNode=null;
}
function OnMouseMove(){
tfUsingArrows=false;
if(tfActiveGrid!=null){
if(tfActiveGrid.Table()!=null){
}
}
}
function OnMouseUp(){
tfUsingArrows=false;
if(tfActiveGrid!=null){
tfActiveGrid.InMouseSelect=false;
}
}
function OnMouseDown(){
tfUsingArrows=false;
if(tfActiveGrid!=null){
tfActiveGrid.InMouseSelect=true;
}
}
function OnKeyUp(){
tfCtrlSelect=false;
tfShiftSelect=false;
tfUsingArrows=false;
}
function OnKeyDown(e){
var nKeyCode=(is.ie?event.keyCode:e.keyCode);
var row=null;
var nX=null;
var rowTR=null;
var newRowTR=null;
switch(nKeyCode){
case 16:
tfShiftSelect=true;
break;
case 17:
tfCtrlSelect=true;
break;
case 32:
if(tfActiveGrid.Rows.ActiveRow!=null){
row=tfActiveGrid.Rows.ActiveRow;
row.SelectRow();
return false;
}
case 38:
tfUsingArrows=true;
if(tfActiveGrid.Rows.ActiveRow!=null){
row=tfActiveGrid.Rows.ActiveRow;
rowTR=_gE(row.HTMLID);
nX=rowTR.rowIndex-1;
newRowTR=rowTR.parentNode.children[nX];
if(newRowTR==null){
return false;
}
if(newRowTR.style.display=='none'){
return false;
}
if(newRowTR.object.indexOf(tfActiveGrid.Name+".Rows")>-1)
{
var newRow=eval(newRowTR.object).GetRowView();
row.DeActivateRow();
newRow.ActivateRow();
tfActiveGrid.Rows.ActiveRow=newRow;
if(!tfActiveGrid.AllowMultiSelect){
newRow.SelectRow();
}
return false;
}
}
break;
case 40:
tfUsingArrows=true;
if(tfActiveGrid.Rows.ActiveRow!=null){
row=tfActiveGrid.Rows.ActiveRow;
rowTR=_gE(row.HTMLID);
nX=rowTR.rowIndex+1;
newRowTR=rowTR.parentNode.children[nX];
if(newRowTR==null){
return;
}
if(newRowTR.style.display=='none'){
return;
}
if(newRowTR.object.indexOf(tfActiveGrid.Name+".Rows")>-1)
{
newRow=eval(newRowTR.object).GetRowView();
row.DeActivateRow();
newRow.ActivateRow();
tfActiveGrid.Rows.ActiveRow=newRow;
if(!tfActiveGrid.AllowMultiSelect){
newRow.SelectRow();
}
return false;
}
}
break;
case 113:
if(tfActiveGrid.Rows.SelectedCell!=null){
tfActiveGrid.Rows.SelectedCell.EditMode();
}
break;
case 46:
if(tfActiveGrid!=null){
tfActiveGrid.GroupByDrager.DeleteGroupBy();
tfActiveGrid.Rows.DeleteSelectedRows();
}
break;
}
}
function Drag(MainTHIS){
this.lvObj=MainTHIS;
function HeaderToGroupBy(){
if(this.lvObj.Events.DragObject==null){return;}
if(this.lvObj.GroupBy.InsertColumn(this.lvObj.Events.DragObject.Key)==false){return;}
this.lvObj.Events.DragObject=null;this.lvObj.Events.dragStop(null);this.lvObj.Initialize();
}
this.HeaderToGroupBy=HeaderToGroupBy;
}
function Initialize(){
if(this.Initialized){
return;
}
var el=_gE(_lvObj.Name+"RDiv");
edAddEvent(document,"mousemove",this.OnMouseMove);
edAddEvent(document,"mouseup",this.OnMouseUp);
edAddEvent(document,"mousedown",this.OnMouseDown);
edAddEvent(el,"keyup",this.OnKeyUp);
edAddEvent(el,"keydown",this.OnKeyDown);
this.Initialized=true;
}
this.Drag=new Drag(_lvObj);
this.Initialize=Initialize;
this.OnMouseMove=OnMouseMove;
this.OnMouseUp=OnMouseUp;
this.OnMouseDown=OnMouseDown;
this.OnKeyUp=OnKeyUp;
this.OnKeyDown=OnKeyDown;
this.dragStart=dragStart;
this.dragGo=dragGo;
this.dragStop=dragStop;
}
function tf_GeneralFunctions(_lvObj){
this.lvObj=_lvObj;
function GarbageArray(aArray){
var aTemp=[];
var nX=0;
for(nX in aArray){
if(aArray[nX]!=null){
aTemp[aTemp.length]=aArray[nX];
}
}
return aTemp;
}
function CloneArray(_Arr){
if(!_Arr){return[];}
var array=[];var iter=_Arr.length;if(iter>3){
var tVal=0;var n=iter%4;if(n>0){
do
{array[tVal]=_Arr[tVal];tVal++;}while(--n);
}n=parseInt(iter/4);do
{array[tVal]=_Arr[tVal];tVal++;array[tVal]=_Arr[tVal];tVal++;array[tVal]=_Arr[tVal];tVal++;array[tVal]=_Arr[tVal];tVal++;}while(--n);
}else
{for(var nX in _Arr){array[nX]=_Arr[nX];}}return array;
}
function XMLHTTP(_lvObj){
this.lvObj=_lvObj;var xmlhttp=false;if(!xmlhttp&&typeof XMLHttpRequest!='undefined'){
try
{xmlhttp=new XMLHttpRequest();}catch(e){xmlhttp=false;}
}if(!xmlhttp&&window.createRequest){
try
{xmlhttp=window.createRequest();}catch(e2){xmlhttp=false;}
}if(!xmlhttp){
try
{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(e3){xmlhttp=false;}
}return xmlhttp;
}
function SendData(_lvObj,setStatus,eventTarget){
if(setStatus!=false){setStatus=true;}
if(setStatus){
_lvObj.Tables.Tables[0].Navigator.SetStatusToUpdating();
}
var xmlhttp=this.XMLHTTP(this.lvObj);
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");xmlhttp.open("POST",window.location,false);
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4){
var response=xmlhttp.responseText;
if(response.split("\n")[0].indexOf("true")>-1){
_lvObj.Datas.AcceptChanges();
if(setStatus){
setTimeout(_lvObj.Tables.Tables[0].Navigator.GetEvalObjectString()+".SetStatusToDone();",1000);
}
if(response.split("\n").length>2){
if(setStatus){
_lvObj.Tables.Tables[0].Navigator.SetStatusToFailed();
}
}
edRaiseEvent(_lvObj.Name,"AfterServerUpdate",_lvObj,response);
}
else{
if(setStatus){
setTimeout(_lvObj.Tables.Tables[0].Navigator.GetEvalObjectString()+".SetStatusToDone();",1000);
}
}
}
};
xmlhttp.SetRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp.send("<?xml version=\"1.0\" encoding=\"utf - 8\"?>"+
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema - instance\" xmlns:xsd=\"http ://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"+
"<soap:Body>"+
"<edlvResponse xmlns=\"http://tempuri.org / \">"+
"<edlvResult><![CDATA["+this.lvObj.Datas.DiffGramXML(eventTarget)+"]]></edlvResult>"+
"</edlvResponse>"+
"</soap:Body>"+
"</soap:Envelope>");
}
this.GarbageArray=GarbageArray;
this.XMLHTTP=XMLHTTP;
this.SendData=SendData;
this.CloneArray=CloneArray;
}
function tf_GroupBy(_lvObj){
this.lvObj=_lvObj;
this.Rows=[];
this.AllRows=[];
this.Columns=[];
this.SelectedGroupBy=null;
this.HTMLOutPutGroupBy="";
function Row(_lvObj,_ID,_ParentRow,_HeaderValue,_HeaderText,_Column,_CellValue,_Level){
this.lvObj=_lvObj;
this.ID=_ID;
this.HMTLTrID=(_ParentRow!=null?_ParentRow.HMTLTrID+"_"+this.ID:"tfGroupByRow_TR_"+this.lvObj.Name+"_"+this.ID);
this.HTMLTblID=(_ParentRow!=null?_ParentRow.HTMLTblID+"_"+this.ID:"tfGroupByRow_Tbl_"+this.lvObj.Name+"_"+this.ID);
this.HTMLGroupByImageID="tfRowIMG_"+this.HTMLTblID;
this.Initialize=false;
this.HeaderText=_HeaderText;
this.HeaderValue=_HeaderValue;
this.CellValue=_CellValue;
this.ParentRow=_ParentRow;
this.DataTable=null;
this.ChildGroupByRows=[];
this.GroupColumn=_Column;
this.ChildDataRows=[];
this.Level=_Level;
function GetEvalObjectString(){
return this.lvObj.Name+".GroupBy.AllRows["+this.ID+"]";
}
function DeActivate(){
if(_gE(this.HTMLTblID)){
_gE(this.HTMLTblID).childNodes[0].childNodes[0].childNodes[0].style.backgroundColor='';
_gE(this.HTMLTblID).childNodes[0].childNodes[0].childNodes[1].style.backgroundColor='';
_gE(this.HTMLTblID).childNodes[0].childNodes[1].childNodes[0].style.backgroundColor='';
}
}
function Activate(){
if(this.lvObj.GroupBy.SelectedGroupBy!=null&&this.lvObj.GroupBy.SelectedGroupBy!=this){
this.lvObj.GroupBy.SelectedGroupBy.DeActivate();
}
_gE(this.HTMLTblID).childNodes[0].childNodes[0].childNodes[0].style.backgroundColor='gray';
_gE(this.HTMLTblID).childNodes[0].childNodes[0].childNodes[1].style.backgroundColor='gray';
_gE(this.HTMLTblID).childNodes[0].childNodes[1].childNodes[0].style.backgroundColor='gray';
this.lvObj.GroupBy.SelectedGroupBy=this;
}
function InsertAfter(newElement,targetElement){
var parent=targetElement.parentNode;
if(parent.lastchild==targetElement){
parent.appendChild(newElement);
}
else{
parent.insertBefore(newElement,targetElement.nextSibling);
}
}
function CreateGroupByGroupTable(TRID,_GroupByRow){
this.lvObj.GroupBy.FillGroupByChildsAndRows(_GroupByRow.ChildDataRows,_GroupByRow);
var currentRow=_gE(TRID);
for(var nY in _GroupByRow.ChildGroupByRows){
var groupByRow=_GroupByRow.ChildGroupByRows[nY];
var groupByRowTR=document.createElement("tr");
groupByRowTR.setAttribute("id",groupByRow.HMTLTrID);
groupByRowTR.setAttribute("style","display:block");
groupByRowTR.setAttribute("object",groupByRow.GetEvalObjectString());
for(var i=0;i<_GroupByRow.Level;i++){
var groupByRowTDLeftSpace=document.createElement("td");
groupByRowTDLeftSpace.setAttribute("style","border-collapse: collapse");
groupByRowTDLeftSpace.setAttribute("onmouseover","this.style.cursor='"+(navigator.appName=="Microsoft Internet Explorer"?"hand":"pointer")+"';");
groupByRowTDLeftSpace.innerHTML="&nbsp;&nbsp;&nbsp;";
groupByRowTR.appendChild(groupByRowTDLeftSpace);
}
var groupByRowTD1=document.createElement("td");
groupByRowTD1.setAttribute("align","left");
groupByRowTD1.setAttribute("colspan",(this.lvObj.Columns.Columns.length+this.lvObj.GroupBy.Columns.length-_GroupByRow.Level));
groupByRowTD1.setAttribute("onmouseover","this.style.cursor='"+(navigator.appName=="Microsoft Internet Explorer"?"hand":"pointer")+"';");
var onclickString=groupByRow.GetEvalObjectString()+".SetVisible('"+groupByRow.HMTLTrID+"',this,'"+groupByRow.HTMLGroupByImageID+"')";
groupByRowTD1.innerHTML="<a onclick=\""+onclickString+"\" href='#'><img border='0' id='"+groupByRow.HTMLGroupByImageID+"' height=15 width=15 src=\""+this.lvObj.ResourcePath+"images/plus.gif\"></a>&nbsp;"+
groupByRow.HeaderText+" ("+groupByRow.ChildDataRows.length+")";
groupByRowTR.appendChild(groupByRowTD1);
this.InsertAfter(groupByRowTR,currentRow);
groupByRowTD1.colSpan=(this.lvObj.Columns.Columns.length+this.lvObj.GroupBy.Columns.length-_GroupByRow.Level);
}
}
function CreateGroupByDataTable(TRID,_GroupByRow){
var currentRow=_gE(this.HMTLTrID);
var currentTable=currentRow.parentNode.parentNode;
var dt=this.lvObj.Tables.InsertTable(_GroupByRow.ChildDataRows,_GroupByRow);
for(var i in dt.Rows){
dt.Rows[i].DataTable=dt;
_gE(this.lvObj.DummyDivHTMLID).innerHTML="<table>"+dt.Rows[i].GetRowView().HTMLOutPutForRow()+"</table>";
this.InsertAfter(_gE(this.lvObj.DummyDivHTMLID).childNodes[0].childNodes[0].childNodes[0],currentRow);
}
}
function SetVisible(TRID,objTD,imgID){
if(this.Initialize==false){
if(this.Level<this.lvObj.GroupBy.Columns.length){
this.CreateGroupByGroupTable(TRID,this);
}
else{
this.CreateGroupByDataTable(TRID,this);
}
this.Initialize=true;
}
var isCloseAction=false;
if(objTD.innerHTML.indexOf("minus.gif")>0){
isCloseAction=true;
}
_gE(imgID).src=(_gE(imgID).src.indexOf("plus.gif")>0?this.lvObj.ResourcePath+"images/minus.gif":this.lvObj.ResourcePath+"images/plus.gif");
var currentRow=_gE(TRID).nextSibling;
var isLastGroupByRow=(currentRow.id.indexOf("tfGroupByRow_TR_")>-1?false:true);
while(currentRow!=null){
var isDataRow=(currentRow.id.indexOf("tfGroupByRow_TR_")>-1?false:true);
if(currentRow.id.indexOf(TRID)<0&&isDataRow==false){
return;
}
if(isDataRow==true){
if(isLastGroupByRow==true){
currentRow.style.display=(isCloseAction==true?'none':'block');
}
else if(isCloseAction==true){
currentRow.style.display='none';
}
}
else{
currentRow.style.display=(isCloseAction==true?'none':'block');
}
currentRow=currentRow.nextSibling;
}
}
function InsertGroupByRow(_HeaderValue,_HeaderText,_Column,_CellValue){
this.ChildGroupByRows[this.ChildGroupByRows.length]=new this.lvObj.GroupBy.Row(this.lvObj,this.lvObj.GroupBy.AllRows.length,this,_HeaderValue,_HeaderText,_Column,_CellValue,this.Level+1);
this.lvObj.GroupBy.AllRows[this.lvObj.GroupBy.AllRows.length]=this.ChildGroupByRows[this.ChildGroupByRows.length-1];
return this.ChildGroupByRows[this.ChildGroupByRows.length-1];
}
function InsertChildDataRow(objRow){
this.ChildDataRows[this.ChildDataRows.length]=objRow;
}
this.InsertGroupByRow=InsertGroupByRow;
this.SetVisible=SetVisible;
this.CreateGroupByDataTable=CreateGroupByDataTable;
this.InsertChildDataRow=InsertChildDataRow;
this.GetEvalObjectString=GetEvalObjectString;
this.DeActivate=DeActivate;
this.Activate=Activate;
this.InsertAfter=InsertAfter;
this.CreateGroupByGroupTable=CreateGroupByGroupTable;
}
function InsertGroupByRow(_HeaderValue,_HeaderText,_Column,_CellValue,_Level){
this.Rows[this.Rows.length]=new Row(this.lvObj,this.AllRows.length,null,_HeaderValue,_HeaderText,_Column,_CellValue,_Level);
this.AllRows[this.AllRows.length]=this.Rows[this.Rows.length-1];
return this.Rows[this.Rows.length-1];
}
function InsertColumn(_ColumnKey){
for(var nX in this.lvObj.Columns.Columns){
if(this.lvObj.Columns.Columns[nX].Key==_ColumnKey){
if(this.IsGroupByColumn(this.lvObj.Columns.Columns[nX].ID)==true){
return false;
}
this.Columns[this.Columns.length]=this.lvObj.Columns.Columns[nX].ID;
return true;
}
}
return false;
}
function IsGroupByColumn(_ColumnID){
for(var nX in this.Columns){
if(this.Columns[nX]==_ColumnID){
return true;
}
}
return false;
}
function FillGroupByChildsAndRows(_ChildDataRows,_GroupByRow){
if(_GroupByRow==null){
this.Rows=[];
}
else{
_GroupByRow.ChildGroupByRows=[];
}
var nColumnNo;
var groupByRows;
var bHasGroup=false;
for(var nX in _ChildDataRows){
bHasGroup=false;
if(_GroupByRow==null){
nColumnNo=this.Columns[0];
groupByRows=this.Rows;
}
else{
nColumnNo=this.Columns[_GroupByRow.Level];
groupByRows=_GroupByRow.ChildGroupByRows;
}
            if (this.lvObj.Datas.GetDataByKeyID("Current", _ChildDataRows[nX].DataKeyID) == null) { continue; }
            var data=_ChildDataRows[nX].GetRowView().Cells.GetCell(this.lvObj.Columns.Columns[nColumnNo].Key).HTMLOutPut().toString();
var cellValue=_ChildDataRows[nX].GetRowView().Cells.GetCell(this.lvObj.Columns.Columns[nColumnNo].Key).Value;
for(var nY in groupByRows){
if(groupByRows[nY].HeaderValue==data){
bHasGroup=true;
groupByRows[nY].InsertChildDataRow(_ChildDataRows[nX]);
break;
}
}
if(bHasGroup==false){
var groupRow;
if(_GroupByRow==null){
groupRow=this.InsertGroupByRow(data,data,this.lvObj.Columns.Columns[nColumnNo],cellValue,(_GroupByRow==null?1:_GroupByRow.Level+1));
}
else{
groupRow=_GroupByRow.InsertGroupByRow(data,data,this.lvObj.Columns.Columns[nColumnNo],cellValue,(_GroupByRow==null?1:_GroupByRow.Level+1));
}
groupRow.InsertChildDataRow(_ChildDataRows[nX]);
}
}
}
function Initialize(){
if(this.Columns.length<1){
var aRows=this.lvObj.Rows.Rows;
var dt=this.lvObj.Tables.InsertTable(aRows,null);
this.HTMLOutPutGroupBy=dt.HTMLOutPut();
return;
}
this.HTMLOutPutGroupBy="<table width='100%' id=\"tflv_"+this.lvObj.Name+"\" class='TableGrouped'>"+
"<tr>"+this.lvObj.Columns.GetHTMLOutPuts()+"</tr>";
this.FillGroupByChildsAndRows(this.lvObj.Rows.Rows);
var _GroupByRow;
for(var nY in this.Rows){
_GroupByRow=this.Rows[nY];
this.HTMLOutPutGroupBy+="<tr id='"+_GroupByRow.HMTLTrID+"' style='display:block;z-index:1;' object='"+_GroupByRow.GetEvalObjectString()+"'> "+
"<td align='left' colspan="+(this.lvObj.Columns.Columns.length+this.lvObj.GroupBy.Columns.length)+
" onmouseover=\"this.style.cursor = '"+(navigator.appName=="Microsoft Internet Explorer"?"hand":"pointer")+
"';\" align='center' onclick=\""+_GroupByRow.GetEvalObjectString()+".SetVisible('"+_GroupByRow.HMTLTrID+
"',this,'"+_GroupByRow.HTMLGroupByImageID+"');\"><img id='"+_GroupByRow.HTMLGroupByImageID+
"' height='15' width='15' src=\""+this.lvObj.ResourcePath+"images/plus.gif\">&nbsp;"+
_GroupByRow.HeaderText+" ("+_GroupByRow.ChildDataRows.length+")</td></tr>";
}
}
this.Initialize=Initialize;
this.Row=Row;
this.InsertGroupByRow=InsertGroupByRow;
this.InsertColumn=InsertColumn;
this.IsGroupByColumn=IsGroupByColumn;
this.FillGroupByChildsAndRows=FillGroupByChildsAndRows;
}
function tf_GroupByDrager(_lvObj){
this.lvObj=_lvObj;
this.ID="tfHM_GroupBy";
this.Visible=true;
this.TabLinkClass="";
this.TabClass="";
this.SelectedGroupBy=null;
function Show(bShow){
_gE(this.ID).style.display=(bShow?'block':'none');
}
function SelectGroupBy(nGroupByIndex){
this.ClearGroupBy();
this.SelectedGroupBy=nGroupByIndex;
}
function ClearGroupBy(){
if(this.SelectedGroupBy!=null){
this.lvObj.GroupByDrager.SelectedGroupBy=null;
}
}
function DeleteGroupBy(){
if(this.SelectedGroupBy==null){
return;
}
var nGroupByColumnIndex=this.lvObj.GroupBy.Columns[this.SelectedGroupBy];
var aDue=this.lvObj.GroupBy.Columns;
this.lvObj.GroupBy.Columns=[];
var alen=aDue.length;
for(var nX=0;nX<alen;nX++){
if(aDue[nX]!=nGroupByColumnIndex){
this.lvObj.GroupBy.InsertColumn(this.lvObj.Columns.Columns[aDue[nX]].Key);
}
}
this.ClearGroupBy();
this.lvObj.Initialize();
}
function HTMLOutPut(){
var sHTMLOutPut="<table width=100% >";
var len=this.lvObj.GroupBy.Columns.length;
for(var nX=0;nX<len;nX++){
sHTMLOutPut+="<tr>"+
(nX>0?"<td colspan="+nX+"></td>":"")+
" <td  "+
" id=\""+this.ID+"_"+this.lvObj.Name+"Hdr"+nX+"\" "+
" onclick=\""+this.lvObj.Name+".GroupByDrager.SelectGroupBy("+nX+"); \""+
" onmouseup=\""+this.lvObj.Name+".Events.Drag.HeaderToGroupBy(); \">&nbsp;"+
this.lvObj.Columns.Columns[this.lvObj.GroupBy.Columns[nX]].Header+"</td>"+
(nX<this.lvObj.GroupBy.Columns.length-1?"<td colspan='"+(this.lvObj.GroupBy.Columns.length-nX)+"'></td>":"")+
"</tr>";
}
if(this.lvObj.GroupBy.Columns.length==0){
sHTMLOutPut+="<tr>"+
"<td "+
" onmouseup=\""+this.lvObj.Name+".Events.Drag.HeaderToGroupBy(); \">"+
"&nbsp;Drag Here...</td>"+
"</tr>";
}
sHTMLOutPut+="</table>";
return sHTMLOutPut;
}
function HTMLOutPuts(){
return this.HTMLOutPut();
}
this.SelectGroupBy=SelectGroupBy;
this.ClearGroupBy=ClearGroupBy;
this.DeleteGroupBy=DeleteGroupBy;
this.HTMLOutPut=HTMLOutPut;
this.HTMLOutPuts=HTMLOutPuts;
this.Show=Show;
}
function tf_Navigator(_lvObj){
this.lvObj=_lvObj;
this.SearchTextBoxHTMLID=this.lvObj.Name+'EDNavTB';
this.StatusBarHTMLID=this.lvObj.Name+"SBar";
this.Visible=true;
this.Table=null;
this.FilteredRows=[];
this.SearchValue="";
this.SearchColumn=-1;
this.PageIndex=1;
this.SortColumnIndex=null;
this.SortRotation=null;
this.RowLimit=this.lvObj.RowLimit;
var nX=0;
function GetEvalObjectString(){
return this.Table.GetEvalObjectString()+".Navigator";
}
function GetPagingPanelHTMLID(){
return this.Table.HTMLID+"PagePanel";
}
function GetSearchPanelHTMLID(){
return this.Table.HTMLID+"SearchPanel";
}
function ChangeRowLimit(nRowCount){
this.PageIndex=1;
this.lvObj.RowLimit=nRowCount;
this.RowLimit=this.lvObj.RowLimit;
this.Table.RePaint();
}
function Sort(nColumnIndex,bNormal,bNoRePaint){
if(this.SortColumnIndex!=nColumnIndex){
this.SortRotation=null;
}
this.SortColumnIndex=nColumnIndex;
if(bNormal==undefined){
if(this.SortRotation==0){
this.SortRotation=1;
}
else{
this.SortRotation=0;
}
}
else if(bNormal){
this.SortRotation=0;
}
else{
this.SortRotation=1;
}
var cleanedFilteredRows=[];
var len=this.FilteredRows.length;
for(var i=0;i<len;i++){
if(this.lvObj.Datas.CurrentDatas[this.FilteredRows[i].DataKeyID]!=null){
cleanedFilteredRows[cleanedFilteredRows.length]=this.FilteredRows[i];
}
}
this.FilteredRows=cleanedFilteredRows;
if(this.SortRotation==1){
this.FilteredRows.sort(this.reverseSort);
}
else{
this.FilteredRows.sort(this.verseSort);
}
if(!bNoRePaint){
this.Table.RePaint();
}
}
function reverseSort(a,b){
var rootObject=a.lvObj;
var nColumnIndex=a.DataTable.Navigator.SortColumnIndex;
var column=rootObject.Columns.Columns[nColumnIndex];
var data1=column.Field.GetDisplayHTML(rootObject.Datas.CurrentDatas[a.DataKeyID].Data[column.ID]).toString();
var data2=column.Field.GetDisplayHTML(rootObject.Datas.CurrentDatas[b.DataKeyID].Data[column.ID]).toString();
if(data1>data2){
return-1;
}
if(data1<data2){
return 1;
}
return 0;
}
function verseSort(a,b){
var rootObject=a.lvObj;
var nColumnIndex=a.DataTable.Navigator.SortColumnIndex;
var column=rootObject.Columns.Columns[nColumnIndex];
var data1=column.Field.GetDisplayHTML(rootObject.Datas.CurrentDatas[a.DataKeyID].Data[column.ID]).toString();
var data2=column.Field.GetDisplayHTML(rootObject.Datas.CurrentDatas[b.DataKeyID].Data[column.ID]).toString();
if(data1>data2){
return 1;
}
if(data1<data2){
return-1;
}
return 0;
}
function Search(sSearchValue,bNotKeyUp){
this.PageIndex=1;
this.SearchValue=sSearchValue;
sSearchValue=sSearchValue.toLowerCase();
if(!bNotKeyUp){
var nKeyCode=(navigator.appName=="Microsoft Internet Explorer"?event.keyCode:e.keyCode);
if(nKeyCode!=13){
return;
}
}
var aNewRows=[];
if(this.SearchValue==""){
for(nX in this.Table.Rows){
aNewRows[aNewRows.length]=this.Table.Rows[nX];
}
this.FilteredRows=aNewRows;
if(this.SortColumnIndex!=""&&this.SortColumnIndex!=null){
this.Sort(this.SortColumnIndex,this.SortRotation,true);
}
this.Table.RePaint();
return;
}
if(this.SearchColumn==-1){
for(nX in this.Table.Rows){
var columns=this.lvObj.Columns.GetColumnsDisplayInTable();
for(var nY in columns){
var data=columns[nY].Field.GetDisplayHTML(this.lvObj.Datas.CurrentDatas[this.Table.Rows[nX].DataKeyID].Data[columns[nY].ID]).toString();
if(data.toLowerCase().indexOf(sSearchValue)>-1){
aNewRows[aNewRows.length]=this.Table.Rows[nX];
break;
}
}
}
}
else{
for(nX in this.Table.Rows){
if(this.Table.Rows[nX].GetRowView().Cells.GetCell(this.SearchColumn).HTMLOutPut().toString().toLowerCase().indexOf(sSearchValue)>-1){
aNewRows[aNewRows.length]=this.Table.Rows[nX];
}
}
}
this.FilteredRows=aNewRows;
if(this.SortColumnIndex!=""&&this.SortColumnIndex!=null){
this.Sort(this.SortColumnIndex,this.SortRotation,true);
}
this.Table.RePaint();
}
function ChangePageIndex(nIndex){
if(isNaN(nIndex)){
alert("Wrong entry");
return;
}
var nPageCount=Math.ceil(this.FilteredRows.length/this.RowLimit);
if(nIndex>nPageCount){
alert("Your selected page index is greater than the page count");
return;
}
if(nIndex<1){
alert("Your selected page index must be greater than 0");
return;
}
this.PageIndex=nIndex;
this.Table.RePaint();
}
function RePaint(){
_gE(this.GetSearchPanelHTMLID()).innerHTML=this.GetSearchPanelHTMLOutPut();
}
function SetStatusToDirty(){
_gE(this.StatusBarHTMLID).innerHTML="<img valign='absmiddle' src=\""+this.lvObj.ResourcePath+"images/note.gif\" />&nbsp;Modified!&nbsp;";
}
function SetStatusToNormal(){
_gE(this.StatusBarHTMLID).innerHTML="&nbsp;";
}
function SetStatusToUpdating(){
_gE(this.StatusBarHTMLID).innerHTML="<img valign='absmiddle' src='"+this.lvObj.ResourcePath+"images/updating.gif' />&nbsp;Updating&nbsp;Changes...&nbsp;";
}
function SetStatusToDone(){
_gE(this.StatusBarHTMLID).innerHTML="<img valign='absmiddle' src='"+this.lvObj.ResourcePath+"images/completed.jpg' />&nbsp;Updated&nbsp;server&nbsp;successfully.&nbsp;";
}
function SetStatusToFailed(){
_gE(this.StatusBarHTMLID).innerHTML="<img valign='absmiddle' src=\""+this.lvObj.ResourcePath+"images/failed.jpg\" />&nbsp;Failed.&nbsp;";
}
function GetFooter(){
return"<table class='edFooter' width='"+this.lvObj.Width+"' id='"+this.GetPagingPanelHTMLID()+"'>"+this.GetPagingPanelHTMLOutPut()+"</table>";
}
function GetPagingPanelHTMLOutPut(){
var nPageCount=Math.ceil(this.FilteredRows.length/this.RowLimit);
var sHTMLOutPut=[];
sHTMLOutPut.push("<tr><td width='10'>&nbsp;</td>");
if(this.lvObj.AllowAdd==true||this.lvObj.AllowDelete==true||this.lvObj.AllowEdit==true||this.lvObj.AllowMoveRows==true){
sHTMLOutPut.push("  <td width='50'><input id='");
sHTMLOutPut.push(this.lvObj.Name);
sHTMLOutPut.push("_upd' type='button' value='Update' align=\"absMiddle\" onclick=\"");
sHTMLOutPut.push(this.GetEvalObjectString());
sHTMLOutPut.push(".lvObj.GeneralFunctions.SendData(");
sHTMLOutPut.push(this.GetEvalObjectString());
sHTMLOutPut.push(".lvObj)\"/>&nbsp;</td>");
if(this.lvObj.AllowAdd){
sHTMLOutPut.push("<td><input id='");
sHTMLOutPut.push(this.lvObj.Name);
sHTMLOutPut.push("_add' type='button' value='New' align=\"absMiddle\" onclick=\"");
sHTMLOutPut.push(this.Table.GetEvalObjectString());
sHTMLOutPut.push(".AddNewRow()\"></td>");
}
if(this.lvObj.AllowDelete){
sHTMLOutPut.push("<td><input id='");
sHTMLOutPut.push(this.lvObj.Name);
sHTMLOutPut.push("_del' type='button' value='Delete' align=\"absMiddle\" onclick=\"");
sHTMLOutPut.push(this.lvObj.GetEvalObjectString());
sHTMLOutPut.push(".Rows.DeleteSelectedRows()\"></td>");
}
if(this.lvObj.AllowMoveRows){
sHTMLOutPut.push("<td><input id='");
sHTMLOutPut.push(this.lvObj.Name);
sHTMLOutPut.push("_mru' type='button' value='Up' align=\"absMiddle\" onclick=\"");
sHTMLOutPut.push(this.Table.GetEvalObjectString());
sHTMLOutPut.push(".MoveRowUp()\"></td>");
sHTMLOutPut.push("<td><input id='");
sHTMLOutPut.push(this.lvObj.Name);
sHTMLOutPut.push("_mrd' type='button' value='Dn' align=\"absMiddle\" onclick=\"");
sHTMLOutPut.push(this.Table.GetEvalObjectString());
sHTMLOutPut.push(".MoveRowDown()\"></td>");
}
}
if(this.lvObj.EnableExport){
sHTMLOutPut.push("<td><img id='");
sHTMLOutPut.push(this.lvObj.Name);
sHTMLOutPut.push("_exp' alt='Export' src='");
sHTMLOutPut.push(this.lvObj.ResourcePath);
sHTMLOutPut.push("images/export.gif '");
sHTMLOutPut.push("onclick=\"__doPostBack('");
sHTMLOutPut.push(this.lvObj.Name);
sHTMLOutPut.push("_exp','');\"");
sHTMLOutPut.push("/>&nbsp;</td>");
}
sHTMLOutPut.push("<td id='");
sHTMLOutPut.push(this.StatusBarHTMLID);
sHTMLOutPut.push("'>&nbsp;</td>");
if(this.lvObj.AllowPaging==true&&this.RowLimit<=this.lvObj.Rows.Rows.length){
sHTMLOutPut.push("<td width='90%' align='right'> Items:&nbsp;<select class='Selectbox' onchange='");
sHTMLOutPut.push(this.GetEvalObjectString());
sHTMLOutPut.push(".ChangeRowLimit(this.options[this.options.selectedIndex].value)'>");
var t="<option value=50 "+(this.RowLimit==50?"Selected":"")+">50</option>"+
"<option value=100 "+(this.RowLimit==100?"Selected":"")+">100</option>"+
"<option value=250 "+(this.RowLimit==250?"Selected":"")+">250</option>"+
"<option value=500 "+(this.RowLimit==500?"Selected":"")+">500</option>";
sHTMLOutPut.push(t);
sHTMLOutPut.push("</select>&nbsp;&nbsp;&nbsp;");
sHTMLOutPut.push("<a href='javascript:");
sHTMLOutPut.push(this.GetEvalObjectString());
sHTMLOutPut.push(".ChangePageIndex(1)'><img valign='bottom' height='15' width='15' border='0' src='");
sHTMLOutPut.push(this.lvObj.ResourcePath);
sHTMLOutPut.push("images/pg-f.gif.ashx'></a>&nbsp;</td>");
sHTMLOutPut.push("<td><a href='javascript:");
sHTMLOutPut.push(this.GetEvalObjectString());
sHTMLOutPut.push(".ChangePageIndex(");
sHTMLOutPut.push(this.PageIndex-1);
sHTMLOutPut.push(")'><img height='15' width='15' border='0' src='");
sHTMLOutPut.push(this.lvObj.ResourcePath);
sHTMLOutPut.push("images/pg-p.gif.ashx'></a>&nbsp;</td>");
sHTMLOutPut.push("<td>&nbsp;&nbsp;<input class='spTxtboxs' id='");
sHTMLOutPut.push(this.lvObj.Name);
sHTMLOutPut.push("sss' size='2' style='width:20' onchange='");
sHTMLOutPut.push(this.GetEvalObjectString());
sHTMLOutPut.push(".ChangePageIndex(this.value)' value='");
sHTMLOutPut.push(this.PageIndex);
sHTMLOutPut.push("'/> / ");
sHTMLOutPut.push(nPageCount);
sHTMLOutPut.push("&nbsp;&nbsp;</td>");
sHTMLOutPut.push("<td><a href='javascript:");
sHTMLOutPut.push(this.GetEvalObjectString());
sHTMLOutPut.push(".ChangePageIndex(");
sHTMLOutPut.push(this.PageIndex+1);
sHTMLOutPut.push(")'><img height='15' width='15' border='0' src='");
sHTMLOutPut.push(this.lvObj.ResourcePath);
sHTMLOutPut.push("images/pg-n.gif.ashx'></a>&nbsp;</td>");
sHTMLOutPut.push("<td><a href='javascript:");
sHTMLOutPut.push(this.GetEvalObjectString());
sHTMLOutPut.push(".ChangePageIndex(");
sHTMLOutPut.push(nPageCount);
sHTMLOutPut.push(")'><img height='15' width='15' border='0' src='");
sHTMLOutPut.push(this.lvObj.ResourcePath);
sHTMLOutPut.push("images/pg-l.gif.ashx'></a>&nbsp;</td>");
}else{
sHTMLOutPut.push("<td width='90%' align='right'></td>");
}
sHTMLOutPut.push("</tr>");
return sHTMLOutPut.join('');
}
function GetSearchPane(){
if(this.lvObj.AllowSearch==true){
var myObj=this.GetEvalObjectString();
var sFieldsOption="<option value=-1>All fields</option>";
var columns=this.lvObj.Columns.GetColumnsDisplayInTable();
for(var nX in columns){
sFieldsOption+="<option value="+columns[nX].Key+" "+(this.SearchColumn==columns[nX].Key?"Selected":"")+">"+columns[nX].Header+"</option>";
}
var sHTMLOutPut="<div class='edSearch' width=\"100 % \"><select class='Selectbox' onchange='"+
myObj+".SearchColumn=this.options[this.options.selectedIndex].value"+"'>"+sFieldsOption+"</select>"+
"   <input class='spTxtboxs' value='"+this.SearchValue+"' onchange='"+myObj+".Search(this.value)' id='"+
this.SearchTextBoxHTMLID+"'></input> <div class='edSearch_img' onclick=\""+myObj+
".Search(_gE('"+this.SearchTextBoxHTMLID+"').value, true);\"></div></div>";
}
return sHTMLOutPut;
}
this.GetPagingPanelHTMLID=GetPagingPanelHTMLID;
this.GetSearchPanelHTMLID=GetSearchPanelHTMLID;
this.ChangePageIndex=ChangePageIndex;
this.ChangeRowLimit=ChangeRowLimit;
this.SetStatusToNormal=SetStatusToNormal;
this.SetStatusToUpdating=SetStatusToUpdating;
this.SetStatusToDone=SetStatusToDone;
this.SetStatusToFailed=SetStatusToFailed;
this.SetStatusToDirty=SetStatusToDirty;
this.Search=Search;
this.Sort=Sort;
this.reverseSort=reverseSort;
this.verseSort=verseSort;
this.GetEvalObjectString=GetEvalObjectString;
this.RePaint=RePaint;
this.GetFooter=GetFooter;
this.GetSearchPane=GetSearchPane;
this.GetPagingPanelHTMLOutPut=GetPagingPanelHTMLOutPut;
}
function tf_RowView(_ID,_Data,_lvObj){
this.lvObj=_lvObj;
this.ID=_ID;
this.HTMLID=this.lvObj.Name+"R"+_ID;
this.SelectionTDHTMLID="RS"+this.lvObj.Name+_ID;
this.Data=_Data;
this.objStr=this.lvObj.Name+".Rows.Rows["+this.lvObj.GetRowMainArrayIndex(_ID)+"]";
this.Cells=new tf_Cells(this.lvObj,this);
this.Cells.Initialize();
this.cStyle="";
this.IsSelected=this.Data.Data[0].charAt(0)=="1"?true:false;
this.IsDisabled=this.Data.Data[0].charAt(1)=="1"?true:false;
function GetEvalObjectString(){
return this.lvObj.Name+".Rows.Rows["+this.lvObj.GetRowMainArrayIndex(this.ID)+"]";
}
function ChangeRowClass(_Class){
var el=_gE(this.HTMLID);
if(el=='undefined'||el==null){return;}
if(_Class!=null){el.className=el.className+' '+_Class;}
else{
var objRE=new RegExp("\\b(edSelRow)\\b","ig");
el.className=el.className.replace(objRE,"");
objRE=null;
}
}
function DisableRow(){
var row=_gE(this.HTMLID);
if(row=='undefined'||row==null){return;}
this.Data.Data[0]=repChar(this.Data.Data[0],'1',1);
row.className="edDRow";
var rowsel=_gE(this.SelectionTDHTMLID);
rowsel.className="RSelD";
}
function DeActivateRow(){
var row=_gE(this.HTMLID);
if(row=='undefined'||row==null){return;}
row.className=this.cStyle;
}
function ActivateRow(){
var row=_gE(this.HTMLID);
if(row=='undefined'||row==null){return;}
this.cStyle=row.className;
row.className=row.className+" edActiveRow";
}
function repChar(s,c,n){
(s=s.split(''))[n]=c;return s.join('');
}
function SelectRow(isMulti,startindex,endindex){
if(this.lvObj.Rows.EditedCell!=null){this.lvObj.Rows.EditedCell.NormalMode();}
if(this.lvObj.AllowGroupBy){this.lvObj.GroupByDrager.ClearGroupBy();}
var swapStatus;
var selectedData;
if(!this.lvObj.AllowMultiSelect){
this.lvObj.Rows.ClearSelectedRows(true);
this.ChangeSelectionStatus(1);
this.IsSelected=true;
this.Data.Data[0]=repChar(this.Data.Data[0],'1',0);
this.ChangeRowClass("edSelRow");
this.lvObj.Rows.SelectedRows[this.lvObj.Rows.SelectedRows.length]=this;
this.lvObj.Rows.Rows[this.lvObj.GetRowMainArrayIndex(this.ID)].IsSelected=true;
selectedData=this.lvObj.Datas.InsertSelectedData(this.Data.KeyID);
this.lvObj.LastSelectedIndex=this.ID;
return;
}
else{
if(!tfShiftSelect){
this.IsSelected=!this.IsSelected;
if(this.IsSelected){
selectedData=this.lvObj.Datas.InsertSelectedData(this.Data.KeyID);
this.ChangeRowClass("edSelRow");
this.ChangeSelectionStatus(1);
this.lvObj.LastSelectedIndex=this.ID;
this.Data.Data[0]=repChar(this.Data.Data[0],'1',0);
}
else{
this.lvObj.Datas.RemoveSelectionData(this.Data.KeyID);
this.ChangeRowClass(null);
this.ChangeSelectionStatus(0);
this.Data.Data[0]=repChar(this.Data.Data[0],'0',0);
}
this.lvObj.Rows.SelectedRows[this.lvObj.Rows.SelectedRows.length]=this;
this.lvObj.Rows.Rows[this.lvObj.GetRowMainArrayIndex(this.ID)].IsSelected=this.IsSelected;
}
else
{
startIndex=this.ID>=this.lvObj.LastSelectedIndex?this.lvObj.LastSelectedIndex+1:this.ID;
endIndex=this.ID>this.lvObj.LastSelectedIndex?this.ID:this.lvObj.LastSelectedIndex-1;
tfShiftSelect=false;
for(var nX=startIndex;nX<=endIndex;nX++){
var row=this.lvObj.Rows.Rows[nX].GetRowView();
var attribs=row.Cells.Cells[0].Value;
tfActiveGrid.Rows.ActiveRow=row;
if(attribs.charAt(1)!='1'){
row.SelectRow(true);
edRaiseEvent(row.lvObj.Name,"AfterRowSelect",row,row.lvObj);
}
}
}
}
}
function ChangeSelectionStatus(_Status){
var sType;
if(this.lvObj.AllowMultiSelect){sType="m";}
else{sType="s";}
var el=_gE(this.SelectionTDHTMLID);
if(el=='undefined'||el==null){return;}
switch(_Status){
case 0:
el.className=sType+"RSelU";
break;
case 1:
el.className=sType+"RSelS";
break;
case 2:
el.innerHTML='*';
break;
case 3:
el.className=sType+"RSelE";
break;
}
}
function Delete(){
debugRows(this.lvObj,"beforeDelete");
var rView=this.lvObj.Rows.Rows[this.lvObj.GetRowMainArrayIndex(this.ID)];
if(!rView){return;}
rView.IsDeleted=true;
var deletedData=this.lvObj.Datas.InsertDeletedData(this.Data.KeyID);
this.Hide();
if(!rView.DataTable){return;}
for(var nX in rView.DataTable.Navigator.FilteredRows){
if(rView.DataTable.Navigator.FilteredRows[nX].DataKeyID==this.Data.KeyID){
rView.DataTable.Navigator.FilteredRows.splice(nX,1);
}
}
this.lvObj.Rows.SelectedRows.length=0;
this.lvObj.Datas.SelectedDatas.length=0;
for(nX in rView.DataTable.Rows){
if(rView.DataTable.Rows[nX].DataKeyID==this.Data.KeyID){
rView.DataTable.Rows.splice(nX,1);
}
}
debugRows(this.lvObj,"AfterDelete");
}
function Hide(){
_gE(this.HTMLID).style.display='none';
}
function Initialize(){
}
function HTMLOutPutForRow(_display){
var style="";
var html=[];
var sTemp="";
var groupByColSpan=0;
if(this.lvObj.AlternateRowTurn){this.lvObj.AlternateRowTurn=false;}
else{this.lvObj.AlternateRowTurn=true;style="class='edARow'";}
if(this.lvObj.AllowMultiSelect){sTemp="mRSelU";}
else{sTemp="sRSelU";}
var attribs=this.Cells.Cells[0].Value;
if(attribs.charAt(0)=='1'){this.ChangeSelectionStatus(1);}
if(attribs.charAt(1)=='1'){style="edDRow";sTemp="RSelD";}
html.push("<tr id='");
html.push(this.HTMLID);
html.push("' ");
html.push(style);
html.push(" onclick='eClk(this);' ondblclick='dClk(this);' ");
html.push((_display!=null?"style='display:"+_display+"'":"")+" object='"+this.objStr+"'>");
if(this.lvObj.Columns.VisibleColumns==null){this.lvObj.Columns.GetVisibleColumns();}
var cell;
for(var nX=0;nX<this.lvObj.Columns.VisibleColumns.length;nX++){
cell=this.Cells.GetCell(this.lvObj.Columns.VisibleColumns[nX].Key);
if(nX==0&&this.lvObj.AllowUserSelection){
html.push("<td colspan='");
html.push(groupByColSpan);
html.push("' id=\"");
html.push(this.SelectionTDHTMLID);
html.push("\" class='");
html.push(sTemp);
html.push("'></td>");
}
else{
html.push("<td id='");
html.push(cell.HTMLID);
html.push("'>");
var strTmp=cell.HTMLOutPut();
if(this.lvObj.Columns.VisibleColumns[nX].allowHTML==true){
strTmp=HTMLDecode(strTmp);
this.lvObj.Columns.setAutoWidth(HRefLength(strTmp),nX);
}
else{
this.lvObj.Columns.setAutoWidth(strTmp.length,nX);
}
html.push(strTmp);
html.push("</td>");
}
}
html.push("</tr>");
return html.join('');
}
function HRefLength(tLink){
var regx2=/^.*\=\"(.*)\">(.*)<.*$/;
regx2=regx2.exec(tLink);
var url2=''
var text2=''
if(regx2&&regx2[1]){
url2=regx2[1]
text2=regx2[2]
}
return text2.length;
}
this.GetEvalObjectString=GetEvalObjectString;
this.DeActivateRow=DeActivateRow;
this.ActivateRow=ActivateRow;
this.SelectRow=SelectRow;
this.DisableRow=DisableRow;
this.ChangeSelectionStatus=ChangeSelectionStatus;
this.ChangeRowClass=ChangeRowClass;
this.CellClass="";
this.Delete=Delete;
this.Hide=Hide;
this.Initialize=Initialize;
this.HTMLOutPutForRow=HTMLOutPutForRow;
}
function tf_Row(_RowIndex,_DataKeyID,_lvObj){
this.lvObj=_lvObj;
this.DataKeyID=_DataKeyID;
this.RowIndex=_RowIndex;
this.RowView=tf_RowView;
this.DataTable=null;
this.IsDeleted=false;
    function GetRowView() { return new this.RowView(this.RowIndex, this.lvObj.GeneralFunctions.CloneArray(this.lvObj.Datas.GetDataByKeyID("Current", this.DataKeyID)), this.lvObj); }
    this.GetRowView=GetRowView;
}
function tf_Rows(_lvObj){
this.lvObj=_lvObj;
this.Row=tf_Row;
this.Rows=[];
this.SelectedRows=[];
this.EditedCell=null;
this.SelectedCell=null;
this.ActiveRow=null;
this.EditedRowWithEditTemplate=null;
this.IsEditTemplateValid=true;
this.IsNewRow=false;
function SelectAllRows(PageOnly){
if(this.lvObj.AllowMultiSelect){
if(!PageOnly){
var totRows=this.lvObj.Rows.Rows.length;
for(var nX=0;nX<totRows;nX++){
var row=this.lvObj.Rows.Rows[nX].GetRowView();
var attribs=row.Cells.Cells[0].Value;
tfActiveGrid.Rows.ActiveRow=row;
if(attribs.charAt(1)!='1'){
row.SelectRow(true);
edRaiseEvent(row.lvObj.Name,"AfterRowSelect",row,row.lvObj);
}
}
return;
}
else{
var nX;
var sInd=this.lvObj.RowLimit*(this.lvObj.Tables.Tables[0].Navigator.PageIndex-1);
var eInd=sInd+this.lvObj.RowLimit;
var nrows=(eInd<=this.Rows.length)?eInd:this.Rows.length;
for(nX=sInd;nX<nrows;nX++){
this.SelectedRows.push(this.lvObj.Datas.CurrentDatas[nX]);
if(this.SelectedRows[this.SelectedRows.length-1].Data[0].charAt(1)!='1'){
this.lvObj.Rows.Rows[nX].IsSelected=true;
replaceChar(this.SelectedRows[this.SelectedRows.length-1].Data[0],'1',0);
}
}
}
this.SetRowAttribs();
this.lvObj.Datas.SelectedDatas=this.lvObj.GeneralFunctions.CloneArray(this.SelectedRows);
edRaiseEvent(this.lvObj.Name,"AfterSelectAll",this.SelectedRows);
}
}
function setRowAttribsX(nrow,clearAll){
if(nrow==null){return;}
if(clearAll){
nrow.ChangeRowClass(null);
nrow.ChangeSelectionStatus(0);
nrow.IsSelected=false;
return;
}
var attribs=nrow.Cells.Cells[0].Value;
if(attribs.charAt(0)=='1'||nrow.IsSelected){
nrow.SelectRow();
}
if(attribs.charAt(1)=='1'){
nrow.DisableRow();
nrow.IsSelected=false;
}
}
function SetRowAttribs(clearAll){
if(!this.lvObj.Tables.Tables[0]){return;}
tfCtrlSelect=true;
var nX;
var sInd=parseInt(this.lvObj.RowLimit)*(this.lvObj.Tables.Tables[0].Navigator.PageIndex-1);
var eInd=parseInt(sInd)+parseInt(this.lvObj.RowLimit);
var nrows=(eInd<=this.lvObj.Tables.Tables[0].Navigator.FilteredRows.length)?eInd:this.Rows.length-1;
var attribs;
for(nX=sInd;nX<=nrows;nX++){
if(!this.Rows[nX].IsDeleted){
arow=this.Rows[nX].GetRowView();
attribs=arow.Cells.Cells[0].Value;
if(attribs!='00'){
setRowAttribsX(arow,clearAll);
arow.Data.Data[0]='00';
}
}
}
tfCtrlSelect=false;
}
function ClearSelectedRowsX(rI){
}
function ClearSelectedRows(blnSetAttr){
if(blnSetAttr){this.SetRowAttribs(true);}
var nX;
var nrows=this.SelectedRows.length;
for(nX=0;nX<nrows;nX++){
if(this.lvObj.Datas.CurrentDatas[nX]){
if(this.lvObj.Datas.CurrentDatas[nX].Data[0].charAt(0)=="1"){
replaceChar(this.lvObj.Datas.CurrentDatas[nX].Data[0],'0',0);
}
}
}
this.SelectedRows.length=0;
this.lvObj.Datas.SelectedDatas.length=0;
edRaiseEvent(this.lvObj.Name,"AfterRowsDeselected",this.lvObj);
}
function HideEditTemplate(){
_gE(this.lvObj.Name+"ModalDlgMask").style.display='none';
_gE(this.lvObj.EditTemplateHTMLID).style.display='none';
}
function ShowEditTemplate(_RowView,IsAdd){
var i;
this.EditedRowWithEditTemplate=_RowView;
var len=_RowView.Cells.Cells.length;
for(i=0;i<len;i++){
this.BeforeEditTemplate(_RowView.Cells.Cells[i]);
}
_gE(this.lvObj.Name+"ModalDlgMask").style.display='block';
_gE(this.lvObj.EditTemplateHTMLID).style.display='block';
if(IsAdd){
this.IsNewRow=true;
var el=_gE(_lvObj.HTMLID);
_gE(this.lvObj.EditTemplateHTMLID).style.top=xTop(el)+40;
_gE(this.lvObj.EditTemplateHTMLID).style.left=xLeft(el)+200;
_gE(this.lvObj.ETemplateTitleHTMLID).innerHTML="Add New Row: "+this.EditedRowWithEditTemplate.ID;
}
else{
_gE(this.lvObj.EditTemplateHTMLID).style.top=xTop(el)+40;
_gE(this.lvObj.EditTemplateHTMLID).style.left=xLeft(el)+200;
_gE(this.lvObj.ETemplateTitleHTMLID).innerHTML="Edit Row: "+this.EditedRowWithEditTemplate.ID;
}
len=_RowView.Cells.Cells.length;
for(i=0;i<len;i++){
this.AfterEditTemplate(_RowView.Cells.Cells[i]);
}
}
function ApplyChanges(){
var i;
this.IsNewRow=false;
edRaiseEvent(this.lvObj.Name,"AfterTemplateOK",this.EditedRowWithEditTemplate);
for(i=0;i<this.EditedRowWithEditTemplate.Cells.Cells.length;i++){
this.AfterEditTemplate(this.EditedRowWithEditTemplate.Cells.Cells[i]);
}
this.HideEditTemplate();
_lvObj.Tables.Tables[0].Navigator.SetStatusToDirty();
}
function CancelChanges(){
if(this.IsNewRow){
this.EditedRowWithEditTemplate.Delete();
this.IsNewRow=false;
}
this.HideEditTemplate();
edRaiseEvent(this.lvObj.Name,"AfterTemplateCancel",this.EditedRowWithEditTemplate);
}
function GetEditTemplateControls(control,columnName,foundControls){
var newFoundControls=[];
if(foundControls==null){
foundControls=[];
}
var len=foundControls.length;
for(var i=0;i<len;i++){
newFoundControls[newFoundControls.length]=foundControls[i];
}
len=control.childNodes.length;
for(i=0;i<len;i++){
if(control.childNodes[i].name==("_"+columnName)){
newFoundControls[newFoundControls.length]=control.childNodes[i];
}
var tempFoundControls=this.GetEditTemplateControls(control.childNodes[i],columnName,foundControls);
for(var ii=0;ii<tempFoundControls.length;ii++){
newFoundControls[newFoundControls.length]=tempFoundControls[ii];
}
}
return newFoundControls;
}
function SetEditTemplateControls(control,value){
if(control.type=='text'){
control.value=value;
}
else if(control.type=='hidden'){
control.value=value;
}
else if(control.type=='checkbox'){
control.checked=value;
}
else if(control.type=='radio'){
if(control.value==value){
control.checked=true;
}
}
else if(control.type=='select'){
for(var i=0;i<control.options.length;i++){
if(control.options[i].value==value){
control.options[i].selected=true;
}
}
}
}
function SetCellValues(control,cell){
if(control.type=='text'){
cell.SetValue(control.value);
}
else if(control.type=='hidden'){
cell.SetValue(control.value);
}
else if(control.type=='checkbox'){
cell.SetValue(control.checked);
}
else if(control.type=='radio'){
if(control.checked==true){
cell.SetValue(control.value);
}
}
else if(control.type=='select'){
cell.SetValue(control.options[control.options.selectedIndex].value);
}
}
function BeforeEditTemplate(cell){
var control=this.GetEditTemplateControls(_gE(this.lvObj.EditTemplateHTMLID),cell.Column.ColumnName,null);
if(control.length!=1){return;}
edRaiseEvent(this.lvObj.Name,"BeforeEditTemplateOnStart",cell,this.EditedRowWithEditTemplate);
this.SetEditTemplateControls(control,cell.Value);
edRaiseEvent(this.lvObj.Name,"BeforeEditTemplateOnEnd",cell,this.EditedRowWithEditTemplate);
}
function AfterEditTemplate(cell){
var controls=this.GetEditTemplateControls(_gE(this.lvObj.EditTemplateHTMLID),cell.Column.ColumnName,null);
var len=controls.length;
for(var i=0;i<len;i++){
if(edRaiseEvent(this.lvObj.Name,"AfterEditTemplateOnStart",cell)==false){
return;
}
}
for(i=0;i<len;i++){
this.SetCellValues(controls[i],cell);
cell.RePaint();
}
for(i=0;i<len;i++){
edRaiseEvent(this.lvObj.Name,"AfterEditTemplateOnEnd",cell);
}
}
function GetEvalObjectString(){
return this.ParentObject.GetEvalObjectString()+".Rows";
}
function InsertRow(_DataKeyID,_lvObj){
this.Rows[this.Rows.length]=new this.Row(this.Rows.length,_DataKeyID,this.lvObj);
return this.Rows[this.Rows.length-1];
}
    function GetRow(_DataKeyID, _RowIndex) { return new this.Row(_RowIndex, this.lvObj.GeneralFunctions.CloneArray(this.lvObj.Datas.GetDataByKeyID("Current", _DataKeyID)), this.lvObj); }
    function RemoveAllRows(){
this.Rows=[];
}
function DeleteSelectedRows(){
var tables=[];
var len=this.SelectedRows.length-1;
for(var nX=len;nX>-1;nX--){
edRaiseEvent(this.lvObj.Name,"BeforeDeleteSelectedRows",this.SelectedRows[nX]);
this.SelectedRows[nX].Delete();
}
if(_lvObj.Tables.Tables[0].Navigator.FilteredRows.length>0){
_lvObj.Tables.Tables[0].Navigator.SetStatusToDirty();
}
edRaiseEvent(this.lvObj.Name,"AfterDeleteSelectedRows",this.SelectedRows[nX]);
}
function HTMLOutPuts(_Childs){
var sRows=[];
sRows.push(this.lvObj.Fields.Header);
for(var nX in _Childs){
sRows.push(_Childs[nX].HTMLOutPut());
}
return sRows.join('');
}
function Initialize(){
this.RemoveAllRows();
for(var nX in this.lvObj.Datas.CurrentDatas){
if(this.lvObj.Datas.CurrentDatas[nX]!=null){
this.InsertRow(this.lvObj.Datas.CurrentDatas[nX].KeyID,this.lvObj);
}
}
}
this.SelectAllRows=SelectAllRows;
this.GetEvalObjectString=GetEvalObjectString;
this.InsertRow=InsertRow;
this.GetRow=GetRow;
this.RemoveAllRows=RemoveAllRows;
this.ClearSelectedRows=ClearSelectedRows;
this.ClearSelectedRowsX=ClearSelectedRowsX;
this.DeleteSelectedRows=DeleteSelectedRows;
this.setRowAttribsX=setRowAttribsX;
this.SetRowAttribs=SetRowAttribs;
this.ShowEditTemplate=ShowEditTemplate;
this.HideEditTemplate=HideEditTemplate;
this.BeforeEditTemplate=BeforeEditTemplate;
this.AfterEditTemplate=AfterEditTemplate;
this.ApplyChanges=ApplyChanges;
this.CancelChanges=CancelChanges;
this.GetEditTemplateControls=GetEditTemplateControls;
this.SetEditTemplateControls=SetEditTemplateControls;
this.SetCellValues=SetCellValues;
this.Initialize=Initialize;
this.HTMLOutPuts=HTMLOutPuts;
}
function tf_Tables(_lvObj){
this.lvObj=_lvObj;
this.Tables=[];
function tf_Table(_lvObj,_ID,_Rows,_GroupBy){
this.lvObj=_lvObj;
this.ID=_ID;
this.HTMLID=this.lvObj.Name+"Tbl"+_ID;
this.RowsHTMLID=this.lvObj.Name+"edTable"+_ID;
this.Navigator=new tf_Navigator(this.lvObj,this);
this.Columns=new tf_Columns(this.lvObj,this);
this.Navigator.Table=this;
this.OriginalRows=_Rows;
this.Navigator.RowLimit=this.lvObj.RowLimit;
this.Rows=[];
for(var nX in _Rows){
this.Navigator.FilteredRows[this.Navigator.FilteredRows.length]=_Rows[nX];
this.Rows[this.Rows.length]=_Rows[nX];
_Rows[nX].DataTable=this;
}
function sendRowUp(CurrentRow,PreviousRow){
PreviousRow.parentNode.insertBefore(CurrentRow,PreviousRow);
}
function MoveRowDown(){
if(!this.lvObj.AllowMultiSelect){
var tbl=_gE(this.RowsHTMLID);
for(var i=0;i<tbl.rows.length-1;i++){
if(tbl.rows[i].className=="edSelRow")
{
edRaiseEvent(this.lvObj.Name,"BeforeMoveRowDown",tbl.rows[i]);
sendRowUp(tbl.rows[i],tbl.rows[i+2]);
return;
}
}
}
return;
}
function MoveRowUp(){
if(!this.lvObj.AllowMultiSelect){
var tbl=_gE(this.RowsHTMLID);
for(var i=1;i<tbl.rows.length;i++){
if(tbl.rows[i].className=="edSelRow")
{
edRaiseEvent(this.lvObj.Name,"BeforeMoveRowUp",tbl.rows[i]);
sendRowUp(tbl.rows[i],tbl.rows[i-1]);
return;
}
}
}
}
function GetEvalObjectString(){
return this.lvObj.Name+".Tables.Tables["+this.ID+"]";
}
function AddNewRow(){
edRaiseEvent(this.lvObj.Name,"BeforeAddNew",this.lvObj);
var fields=this.lvObj.Columns.Columns;
var data=[];
for(var nX in fields){
if(this.lvObj.Columns.Columns[nX].AutoIncrement==true){
this.lvObj.Columns.Columns[nX].LastAutoIncrementID--;
data[nX]=this.lvObj.Columns.Columns[nX].LastAutoIncrementID;
}
else{
data[nX]=this.lvObj.Columns.Columns[nX].DefaultValue;
}
}
var groupBy=this.GroupBy;
while(groupBy!=null){
data[groupBy.GroupColumn.ID]=groupBy.CellValue;
groupBy=groupBy.ParentRow;
}
var currentDataIndex=this.lvObj.Datas.Insert(data);
var row=this.lvObj.Rows.InsertRow(currentDataIndex,this.lvObj);
this.OriginalRows[this.OriginalRows.length]=row
this.Navigator.FilteredRows[this.Navigator.FilteredRows.length]=row;
this.Rows[this.Rows.length]=row;
row.DataTable=this;
var newRow=row.GetRowView();
this.Navigator.Table.RePaint();
newRow.lvObj.Rows.ShowEditTemplate(newRow,true);
debugRows(this.lvObj,"AfterAddNewRow");
}
function ChangePageIndex(nIndex){
if(isNaN(nIndex)){
alert("Wrong entry");
return;
}
if(this.PageIndex==nIndex){
return;
}
var nPageCount=Math.ceil(this.Navigator.FilteredRows.length/this.RowLimit);
if(nIndex>nPageCount){
alert("Your selected page index is greater than the page count");
return;
}
if(nIndex<1){
alert("Your selected page index must be greater than 0");
return;
}
this.PageIndex=nIndex;
this.RePaint();
}
function ChangeRowLimit(nRowCount){
this.lvObj.RowLimit=this.RowLimit=nRowCount;
this.RePaint();
}
function Sort(nColumnIndex,bNormal,bNoRePaint){
this.SortColumnIndex=nColumnIndex;
this.SortRotation=bNormal;
tfActiveGrid.LastSortColumnIndex=nColumnIndex;
if(bNormal){
this.Navigator.FilteredRows.sort(this.verseSort);
}
else{
this.Navigator.FilteredRows.sort(this.reverseSort);
}
this.Navigator.FilteredRows=[];
for(var nX in this.Rows){
this.Navigator.FilteredRows[nX]=this.Rows[nX];
}
if(!bNoRePaint){
this.RePaint();
}
}
function reverseSort(a,b){
var nColumnIndex=tfActiveGrid.LastSortColumnIndex;
if(tfActiveGrid.Columns.Columns[nColumnIndex].GetText(a.Data[nColumnIndex])>tfActiveGrid.Columns.Columns[nColumnIndex].GetText(b.Data[nColumnIndex])){
return-1;
}
if(tfActiveGrid.Columns.Columns[nColumnIndex].GetText(a.Data[nColumnIndex])<tfActiveGrid.Columns.Columns[nColumnIndex].GetText(b.Data[nColumnIndex])){
return 1;
}
return 0;
}
function verseSort(a,b){
var nColumnIndex=tfActiveGrid.LastSortColumnIndex;
if(tfActiveGrid.Columns.Columns[nColumnIndex].GetText(a.Data[nColumnIndex])>tfActiveGrid.Columns.Columns[nColumnIndex].GetText(b.Data[nColumnIndex])){
return 1;
}
if(tfActiveGrid.Columns.Columns[nColumnIndex].GetText(a.Data[nColumnIndex])<tfActiveGrid.Columns.Columns[nColumnIndex].GetText(b.Data[nColumnIndex])){
return-1;
}
return 0;
}
function RePaint(){
if(this.lvObj.Rows.EditedCell!=null){this.lvObj.Rows.EditedCell.NormalMode();}
_gE(this.lvObj.Name+"RDiv").innerHTML=this.HTMLOutPut();
this.lvObj.initProcess(this.loadRows,500,this.Navigator.RowLimit*(this.Navigator.PageIndex-1),this.lvObj);
_gE(this.lvObj.Name+"Ftr").innerHTML=this.lvObj.Tables.Tables[0].Navigator.GetFooter();
if(this.lvObj.AllowUserSelection){edMenu(this.lvObj.Name,10,'mouseover');}
}
function HTMLOutPutX(rI){
if(!this.Navigator.FilteredRows[rI]){
return"";
}
if(this.lvObj.Rows.Rows[this.lvObj.GetRowMainArrayIndex(this.Navigator.FilteredRows[rI].RowIndex)].IsDeleted==true){
return"";
}
this.Navigator.FilteredRows[rI].Table=this;
return this.Navigator.FilteredRows[rI].GetRowView().HTMLOutPutForRow();
}
function HTMLOutPut()
{
var arrHTML=[];
arrHTML.push("<table style='width:");
arrHTML.push(this.lvObj.Width);
arrHTML.push("px;' id='");
arrHTML.push(this.RowsHTMLID);
arrHTML.push("' class='");
if(this.lvObj.FreezeHeader){arrHTML.push("edTable ");}
arrHTML.push("edRow edHeader' ");
arrHTML.push("onmouseover='if(really_over(this)){");
arrHTML.push(this.lvObj.Name);
arrHTML.push(".Activate();}' onmouseout='if(really_out(this)){");
arrHTML.push(this.lvObj.Name);
arrHTML.push(".DeActivate();}'>");
arrHTML.push(this.lvObj.Columns.GetHeaderPane(this));
arrHTML.push("</table>");
return arrHTML.join('');
}
function updLoading(_ro,wid,nX,tRows){
_ro.lvLoad.innerHTML="<div class=\"edLoadTxt\" style=\"width:"+wid+"\"> Rendering "+nX+" of "+tRows+" . . .</div>";
}
function loadRows(n,i,nX,_lvObj){
if(_lvObj.Columns.Columns.length<3){return};
var j=0,IsComplete=false;
var arrHTML=[];
var tbl=_gE(_lvObj.HTMLID);
var arrRows=_lvObj.Tables.Tables[0].Navigator.FilteredRows;
var atrRows=[];
var tRows=_lvObj.RowLimit<=arrRows.length?_lvObj.RowLimit:arrRows.length;
var nRow;
var theSpan;
var wid;
var eInd=_lvObj.Tables.Tables[0].Navigator.RowLimit*_lvObj.Tables.Tables[0].Navigator.PageIndex;
wid=((++i*n)/tRows)*92+"%";
window.setTimeout(function(){updLoading(_lvObj,wid,nX,tRows)},0);
do{
if(!arrRows[nX]){break;}
if(arrRows[nX].IsDeleted==true){nX++;continue;}
nRow=arrRows[nX].GetRowView();
arrHTML.push(nRow.HTMLOutPutForRow());
if(nRow.Cells.Cells[0].Value!='00'){
atrRows.push(nRow);
}
nX++;j++;
}while(nX<eInd&&(j<n));
wid=((++i*n)/tRows)*92+"%";
window.setTimeout(function(){updLoading(_lvObj,wid,nX,tRows)},0);
theSpan=tbl.parentNode.innerHTML.slice(0,-8);
tbl.parentNode.innerHTML=theSpan+arrHTML.join('')+'</TABLE>';
arrHTML.length=0;
if(arrRows[nX]&&nX<_lvObj.Tables.Tables[0].Navigator.RowLimit*_lvObj.Tables.Tables[0].Navigator.PageIndex){
window.setTimeout(function(){loadRows(n,i,nX,_lvObj)},0);
}
else{
_lvObj.completeProcess(_lvObj);
if(_lvObj.FreezeHeader=="true"){
edFreezeHeader(_lvObj.Name,_lvObj.Columns.VisibleColumns);
}
for(i=0;i<atrRows.length;i++){
_lvObj.Rows.setRowAttribsX(atrRows[i],false);
}
if(_lvObj.AllowMultiSelect){edMenu(_lvObj.Name,10,'mouseover');}
_lvObj.lvLoad.innerHTML="";
edRaiseEvent(_lvObj.Name,"AfterRowsLoaded",_lvObj);
}
}
function Initialize(){
}
this.loadRows=loadRows;
this.AddNewRow=AddNewRow;
this.MoveRowUp=MoveRowUp;
this.MoveRowDown=MoveRowDown;
this.GetEvalObjectString=GetEvalObjectString;
this.Initialize=Initialize;
this.HTMLOutPut=HTMLOutPut;
this.HTMLOutPutX=HTMLOutPutX;
this.RePaint=RePaint;
this.GroupBy=_GroupBy;
}
function InsertTable(_Rows,_GroupBy){
this.Tables[this.Tables.length]=new tf_Table(this.lvObj,this.Tables.length,_Rows,_GroupBy);
return this.Tables[this.Tables.length-1];
}
this.InsertTable=InsertTable;
}
function disableTextSel(target){
if(target!=null){
if(typeof target.onselectstart!="undefined")
{target.onselectstart=function(){return false;};}
else if(typeof target.style.MozUserSelect!="undefined")
{target.style.MozUserSelect="none";}
else{
target.onmousedown=function(){return false;};
}
}
}
function dClk(obj){
var row=eval(obj.object).GetRowView();
row.ActiveRow=this;
var attribs=row.Cells.Cells[0].Value;
if(attribs.charAt(1)!='1'){
edRaiseEvent(row.lvObj.Name,"RowDblClick",row,attribs);
}
if(row.lvObj.AllowEdit==true&&tfCtrlSelect==false&&tfShiftSelect==false){
if(attribs.charAt(1)!='1'){
row.lvObj.Rows.ShowEditTemplate(row);
}
}
}
function eClk(obj){
if(tfActiveGrid.Table().style.cursor=="e-resize"){return;}
if(!tfActiveGrid.AllowUserSelection){return;}
var row=eval(obj.object).GetRowView();
var attribs=row.Cells.Cells[0].Value;
edRaiseEvent(row.lvObj.Name,"RowClick",row,attribs);
tfActiveGrid.Rows.ActiveRow=row;
if(attribs.charAt(1)!='1'){
row.SelectRow();
edRaiseEvent(row.lvObj.Name,"AfterRowSelect",row,row.lvObj);
}
return;
}
tfListView=function(sName,sDivName,sHeader,sRender){
this.DataSetName=null;
this.RenderOnClient=sRender;
this.DataSetTableName=null;
this.TableName=null;
this.Name=sName;
this.HTMLID=this.Name+"edTable0";
this.EditTemplateHTMLID=this.Name+"EditTemplate";
this.ETemplateTitleHTMLID=this.Name+"TTitle";
this.DummyDivHTMLID=this.Name+"DDiv";
this.aSortImage=['SortAZ.gif','SortZA.gif'];
this.DivName=sDivName;
this.Height=null;
this.Width=null;
this.ResourcePath="Triad.Controls/";
this.TableClass=null;
this.ReadOnly=false;
this.AllowEdit=false;
this.AllowDelete=false;
this.AllowAdd=false;
this.AllowPaging=false;
this.AllowSearch=false;
this.AllowMoveRows=false;
this.AllowUserSelection=true;
this.FreezeColumnOne=false;
this.FreezeHeader=false;
this.DebugMode=false;
this.AllowGroupBy=false;
this.StaticTable=true;
this.EnableExport=true;
this.AllowResize=true;
this.AllowSorting=false;
this.AllowMultiSelect=false;
this.AlternateRowTurn=true;
this.VisibleColumnCount=0;
this.RowLimit=10000;
this.LastSelectedIndex=-1;
this.LastSortFieldIndex="";
this.GroupByDrager=new tf_GroupByDrager(this);
this.Datas=new tf_Datas(this);
this.Tables=new tf_Tables(this);
tfFields.lvObj=this;
this.Fields=tfFields;
this.Columns=new tf_Columns(this);
this.Rows=new tf_Rows(this);
this.GroupBy=new tf_GroupBy(this);
this.Events=new tf_Events(this);
this.oVBar=null;
this.GeneralFunctions=new tf_GeneralFunctions(this);
this.lvCon=_gE(this.Name+"Container");
this.lvLoad=_gE(this.Name+"loadingDiv");
this.lvLoad.style.display='none';
this.AdjWidth=new tf_AdjWidth(this);
function initProcess(fn,n,nX,_lvObj){
if(this.GetRowCount()>0){
this.lvLoad.style.display="block";
this.lvLoad.innerText="Rendering 0 of "+this.Rows.Rows.length+" . . .";
fn(n,0,nX,_lvObj);
}
}
function completeProcess(_lvObj){
this.lvLoad.innerHTML="";
window.setTimeout(function(){_lvObj.lvLoad.style.display="none";},1000);
}
function GetRowMainArrayIndex(_RowIndex){
var nX=0;
var nrows=this.Rows.Rows.length;
for(nX=0;nX<nrows;nX++){
if(this.Rows.Rows[nX].RowIndex==_RowIndex){
return nX;
}
}
}
function GetEvalObjectString(){
return this.Name;
}
function Table(){
return _gE(this.Name+"edTable0");
}
function Browser(){
var ua,s,i;
this.isIE=false;
this.isNS=false;
this.version=null;
ua=navigator.userAgent;
s="MSIE";
if((i=ua.indexOf(s))>=0){
this.isIE=true;
this.version=parseFloat(ua.substr(i+s.length));
return;
}
s="Netscape6/";
if((i=ua.indexOf(s))>=0){
this.isNS=true;
this.version=parseFloat(ua.substr(i+s.length));
return;
}
s="Gecko";
if((i=ua.indexOf(s))>=0){
this.isNS=true;
this.version=6.1;
return;
}
}
function toggleLoad(tType,_id){
if(tType==undefined){tType='none';}
var el=_gE(_id);
el.style.display=tType;
}
function callWithSetTimeout(funcRef,a,b,c,d,e,f,g){
return function(){funcRef(a,b,c,d,e,f,g);};
}
function showLoad(){
if(this.lvLoad.style.display=='block'){return;}
setTimeout(callWithSetTimeout(toggleLoad,'block',this.Name+"loadingDiv"),1);
}
function hideLoad(){
setTimeout(callWithSetTimeout(toggleLoad,'none',this.Name+"loadingDiv"),1);
}
function onScrollDiv(){
}
function Activate(){
tfActiveGrid=this;
disableTextSel(_gE(tfActiveGrid.Name+'edTable0'));
}
function DeActivate(){}
this.GetSelectionList=function(){
return this.Rows.SelectedRows;
};
this.GetAllRows=function(){
return this.Rows.Rows;
};
this.GetSelectionCount=function(){
var i=0,tot=0;
var len=this.Datas.CurrentDatas.length;
for(i=0;i<len;i++){
if(this.Datas.CurrentDatas[i].Data[0].charAt(0)!="1"){
continue;
}
tot++;
}
return tot;
};
this.GetRowCount=function(){
return this.Datas.CurrentDatas.length;
};
this.UpdateServer=function(eventTarget){
this.GeneralFunctions.SendData(this,true,eventTarget);
};
this.Refresh=function(){
this.Tables.Tables[0].RePaint();
};
this.SortByCell=function(colName,bNormal,bNoRePaint){
if(isNaN(colName)){
colName=this.Columns.GetColumnIndex(colName);
}
this.Tables.Tables[0].Navigator.Sort(colName,bNormal,bNoRePaint);
};
this.GetCellByRow=function(rowId,cell){
if(isNaN(cell)){
return this.Rows.Rows[rowId].GetRowView().Cells.GetCell(cell).Value;
}
else{
return this.Rows.Rows[rowId].GetRowView().Cells.Cells[cell].Value;
}
};
this.SetCellByRow=function(rowId,cell,value){
if(isNaN(cell)){
cell=this.Columns.GetColumnIndex(cell);
}
if(cell!=-1){
this.Datas.CurrentDatas[this.GetRowMainArrayIndex(rowId)].Data[cell]=value;
}
};
this.SelectRow=function(rowId){
this.Rows.Rows[rowId].GetRowView().SelectRow();
replaceChar(this.Datas.CurrentDatas[this.GetRowMainArrayIndex(rowId)].Data[cell],'1',0);
};
this.DisableRow=function(rowId){
this.Rows.Rows[rowId].GetRowView().DisableRow();
};
this.AddNewRow=function(){
this.Tables.Tables[0].AddNewRow();
};
this.initProcess=initProcess;
this.completeProcess=completeProcess;
this.onScrollDiv=onScrollDiv;
this.showLoad=showLoad;
this.hideLoad=hideLoad;
this.Initialize=Initialize;
this.Activate=Activate;
this.DeActivate=DeActivate;
this.Browser=new Browser();
this.GetEvalObjectString=GetEvalObjectString;
this.GetRowMainArrayIndex=GetRowMainArrayIndex;
this.Table=Table;
}
function Initialize(){
if(_gE(this.Name+'edTable0')==null&&!this.RenderOnClient){return;}
if(this.Rows.EditedCell!=null){this.Rows.EditedCell.NormalMode();}
this.GroupByDrager.ClearGroupBy();
this.Rows.Initialize();
this.Fields.Initialize();
this.GroupBy.Rows=[];
this.GroupBy.AllRows=[];
this.GroupBy.Initialize();
this.Events.Initialize();
var html=[];
if(this.RenderOnClient){
if(this.AllowGroupBy){
html.push(this.AllowGroupBy==true?"<div id='"+this.Name+"GroupByDrager'>"+this.GroupByDrager.HTMLOutPuts()+"</div>":"");
html.push(this.AllowSearch==true?this.Tables.Tables[0].Navigator.GetSearchPane():"");
_gE(this.Name+"Hdr").innerHTML=html.join('');
html.length=0;
html.push("<table id='");
html.push(this.Name);
html.push("edTable0' style='width:");
html.push(this.Width);
html.push("px;'class='lvMainD' style='table-layout:fixed;' onmouseover='");
html.push(this.Name);
html.push(".Activate();' onmouseout='");
html.push(this.Name);
html.push(".DeActivate();'");
html.push("><tr>\n<td id='");
html.push(this.Name);
html.push("GroupBy'>");
html.push(this.GroupBy.HTMLOutPutGroupBy);
html.push("</td>\n</tr>\n</table>");
_gE(this.DivName).innerHTML=html.join('');
html.length=0;
html.push(this.Tables.Tables[0].Navigator.GetFooter());
html.push("<div id='");
html.push(this.DummyDivHTMLID);
html.push("'></div>");
_gE(this.Name+"Ftr").innerHTML=html.join('');
}
else{
if(this.AllowSearch){_gE(this.Name+"Hdr").innerHTML=this.Tables.Tables[0].Navigator.GetSearchPane();}
html.length=0;
html.push(this.GroupBy.HTMLOutPutGroupBy);
_gE(this.DivName).innerHTML=html.join('');
html.length=0;
html.push(this.Tables.Tables[0].Navigator.GetFooter());
html.push("<div id='");
html.push(this.DummyDivHTMLID);
html.push("'></div><div id='");
html.push(this.Name);
html.push("BMk'></div>");
_gE(this.Name+"Ftr").innerHTML=html.join('');
}
}
this.initProcess(this.Tables.Tables[0].loadRows,250,0,this);
this.RenderOnClient=true;
edRaiseEvent(this.Name,"AfterInitialized",this);
var edTab=_gE(this.Name+"edTableH");
if(edTab!=null){
this.AdjWidth.Initialize(edTab);
}
else{
edTab=_gE(this.Name+"HD");
this.AdjWidth.Initialize(edTab);
}
}
function debugRows(_lvObj,stask){
var str1='Rows: '+_lvObj.Rows.Rows.length;
str1+=' | SelectedRows: '+_lvObj.Rows.SelectedRows.length;
str1+=' | CurrentDatas: '+_lvObj.Datas.CurrentDatas.length;
str1+=' | OrginalDatas: '+_lvObj.Datas.OrginalDatas.length;
str1+=' | AddedDatas: '+_lvObj.Datas.AddedDatas.length;
str1+=' | SelectedDatas: '+_lvObj.Datas.SelectedDatas.length;
str1+=' | ModifiedDatas: '+_lvObj.Datas.ModifiedDatas.length;
str1+=' | DeletedDatas: '+_lvObj.Datas.DeletedDatas.length;
str1+=' | FilteredRows:'+_lvObj.Tables.Tables[0].Navigator.FilteredRows.length;
top.debug(str1,stask);
}
